<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _mean_absolute_error(y, y_pred, w):
 """Calculate the mean absolute error."""

    return np.average(np.abs(y_pred - y), weights=w)