Data Science and Machine Learning Metrics

This page is a quick reference for common metrics across tasks like classification, regression, and clustering. Each entry includes a definition, when to use it, and links to an explanation (mostly from Wikipedia) and the relevant scikit-learn doc. This list is not meant to be exhaustive.

Metrics explained

A metric is a number that measures model performance, or how well predictions match actual outcomes.

  • In supervised learning, metrics evaluate prediction quality (e.g. RMSE, F1).
  • In unsupervised learning, they assess structure or similarity (e.g. silhouette score).
  • During training, metrics guide choices like model selection and early stopping.

Metrics tables

Classification

Metric Code Details
Accuracy skl Accuracy. Proportion of correct predictions to total predictions. Simple and intuitive. Can be very misleading for imbalanced classes.
Precision skl Precision. True Positives / (True Positives + False Positives). How many predicted positives are correct.
Recall skl Recall. True Positives / (True Positives + False Negatives). How many actual positives were captured.
F1 skl F1 Score. Harmonic mean of precision and recall. Good for imbalanced classes.
ROC AUC skl ROC AUC. Area under the ROC curve. Evaluates ranking performance across thresholds.
PR AUC skl PR AUC. Area under the Precision-Recall curve. Better than ROC AUC for rare positives.
Log Loss skl Logarithmic Loss. Penalizes confident wrong predictions. Common in probabilistic classifiers.
Balanced Acc skl Balanced Accuracy. Mean recall across classes. Helps with imbalanced classes.
MCC skl Matthews Correlation Coefficient Balanced score even for class imbalance. Based on confusion matrix.

Regression

Metric Code Details
MSE skl Mean Squared Error. Average squared difference between predictions and true values. Penalizes larger errors more; sensitive to outliers. Not in original units.
RMSE skl Root Mean Squared Error. Same as MSE but in the original unit scale; easier to interpret. Still sensitive to outliers.
MAE skl Mean Absolute Error. Average absolute difference between predictions and actual values. More robust to outliers than MSE.
skl Coefficient of Determination. Measures proportion of variance explained by the model. Can be negative.
Adj R² Adjusted R². Like R² but penalizes for additional predictors. Helps avoid overfitting.
MSLE skl Mean Squared Log Error. MSE on log-transformed targets. Good for targets spanning orders of magnitude.
MAPE skl Mean Absolute Percentage Error. Average of absolute percentage errors. Can blow up if targets are near zero.
SMAPE Symmetric MAPE. Like MAPE but less sensitive to small denominators. Often used in time series.