Since regression predicts a continuous number rather than a category, its accuracy is measured differently than classification — with metrics quantifying how far off predictions typically are.
from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
import numpy as np
predictions = model.predict(X_test)
mae = mean_absolute_error(y_test, predictions) # average absolute error, in original units
mse = mean_squared_error(y_test, predictions) # average squared error — penalizes big misses more
rmse = np.sqrt(mse) # square root of MSE, back in original units
r2 = r2_score(y_test, predictions) # proportion of variance explained (0 to 1, higher better)
print(f"MAE: {mae:.2f}, RMSE: {rmse:.2f}, R²: {r2:.3f}")
MAE (Mean Absolute Error) reports the average error in the same units as the target — "on average, predictions are off by $15,000" is directly interpretable to anyone familiar with the domain, regardless of statistics background. MSE (Mean Squared Error) squares each error before averaging, which disproportionately penalizes large mistakes over small ones — useful when big errors are genuinely much worse than small ones in the real-world context, but harder to interpret directly since it's in squared units. RMSE (Root Mean Squared Error) takes MSE's square root, bringing it back to the target's original units while retaining the "big errors matter more" property.
R² (R-squared), ranging roughly from 0 to 1 (though it can go negative for a genuinely bad model), reports the proportion of the target's variance the model explains — an R² of 0.85 means the model accounts for 85% of the variation in the target, with the remaining 15% left unexplained by the features used. Rather than looking at any single metric in isolation, reporting MAE or RMSE alongside R² gives both a concrete, real-units sense of typical error size and a normalized sense of overall model quality — useful for comparing models across different problems with different target scales.