liveBook · Manning

Mean absolute error

As explained in Vibe Engineering

Mean absolute error is a regression metric equal to the average absolute difference between predicted and actual values.

Mean absolute error (MAE) measures the average absolute difference between predicted and actual values. Because over- and underestimates both count as positive errors, MAE expresses average prediction error in the same units as the target. section 4.5.4 section 4.5.5

An average is not a guarantee for any individual prediction. A model with an MAE of 77.50 INR can still miss a particular price by hundreds of rupees. Compare MAE with root mean squared error (RMSE), which penalizes large errors more heavily, and inspect predicted-versus-actual plots for patterns that a single average hides. section 4.5.5

Listing 4.5 Evaluating the model’s performance
Y_pred = model.predict(X_test)
 
r2 = r2_score(Y_test, Y_pred)
mae = mean_absolute_error(Y_test, Y_pred)
rmse = np.sqrt(np.mean((Y_test - Y_pred)**2))
 

This test-set evaluation computes MAE from actual and predicted values alongside R² and RMSE. section 4.5.4

Drug-price prediction

A random forest model produced an MAE of 77.50 INR and an RMSE of 179.69 INR. A revised model reduced MAE to 57.98 INR, roughly 25% lower, while RMSE rose slightly and R² fell. The lower average error is useful, but it does not establish that the model improved on every criterion. Because several changes were combined, isolated tests would be needed to assess their individual contributions. section 4.5.5 section 4.5.6

Figure 4.8 Predicted vs. Actual Drug Price: This visualization compares actual drug prices against the model's predictions. The dashed identity line represents perfect accuracy, while the blue dots show real-world performance. The plot illustrates a high concentration of accurate predictions for low-cost medications, with increasing variance and under-prediction as actual drug prices rise.

The predicted-versus-actual plot shows increasing variation and underprediction as actual prices rise, revealing behavior that MAE alone does not show. section 4.5.5

How Vibe Engineering covers it

How deep it goes
Defines absolute-error averaging and interprets its limits, then compares baseline and revised model metrics without isolating individual improvements.
Examples
Compares drug-price prediction errors of 77.50 INR and 57.98 INR across two model evaluations.
What you can do after
Evaluate regression predictions by interpreting MAE in target units and checking complementary metrics for large errors.
How it connects
Connects MAE with root mean squared error, R-squared, predicted-versus-actual plots, and ablation studies.

Also explained in

Compare how 15 books explain mean absolute error →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.