From the confusion matrix to cross-validation -- these memory tricks lock in every model evaluation metric, when to use each one, and how to honestly report your results.
Or continue to the sub-topics below for more specialized Study Rooms and Forums
Proven Mnemonics & Acronyms — fast to learn, hard to forget.
from sklearn.metrics import classification_report
print(classification_report(y_test, y_pred))
# Shows precision, recall, F1 for EACH class
# Always run this on imbalanced datasets — never just accuracyfrom sklearn.metrics import classification_report
print(classification_report(y_test, y_pred))
# Shows precision, recall, F1 for EACH class
# Always run this on imbalanced datasets — never just accuracyfrom sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
mse = mean_squared_error(y_test, y_pred)
mae = mean_absolute_error(y_test, y_pred)
rmse = mean_squared_error(y_test, y_pred, squared=False)
r2 = r2_score(y_test, y_pred)from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
mse = mean_squared_error(y_test, y_pred)
mae = mean_absolute_error(y_test, y_pred)
rmse = mean_squared_error(y_test, y_pred, squared=False)
r2 = r2_score(y_test, y_pred)from sklearn.model_selection import StratifiedKFold, cross_val_score
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
scores = cross_val_score(model, X, y, cv=skf, scoring="f1")
print(f"F1: {scores.mean():.3f} ± {scores.std():.3f}")from sklearn.model_selection import StratifiedKFold, cross_val_score
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
scores = cross_val_score(model, X, y, cv=skf, scoring="f1")
print(f"F1: {scores.mean():.3f} ± {scores.std():.3f}")from sklearn.calibration import CalibratedClassifierCV, calibration_curve
calibrated = CalibratedClassifierCV(base_model, method="sigmoid")
calibrated.fit(X_train, y_train)
fraction_pos, mean_pred = calibration_curve(y_test, y_prob, n_bins=10)from sklearn.calibration import CalibratedClassifierCV, calibration_curve
calibrated = CalibratedClassifierCV(base_model, method="sigmoid")
calibrated.fit(X_train, y_train)
fraction_pos, mean_pred = calibration_curve(y_test, y_prob, n_bins=10)