Grasp Fundamental Metrics for Classification and Regression
Start with basics: accuracy, precision, recall, F1 for classification; MSE, MAE, R² for regression.
Classification Example (Scikit-learn)
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
y_true = [0, 1, 1, 0]
y_pred = [0, 1, 0, 0]
print(accuracy_score(y_true, y_pred)) # 0.75
precision, recall, f1, support = precision_recall_fscore_support(y_true, y_pred)
print(precision) # [1.0, 0.5]
print(recall) # [1.0, 0.5]
print(f1) # [1.0, 0.5]
Regression Example
from sklearn.metrics import mean_squared_error
y_true_reg = [3, -0.5, 2, 7]
y_pred_reg = [2.5, 0.0, 2, 8]
print(mean_squared_error(y_true_reg, y_pred_reg)) # 0.375
Read Scikit-learn Metrics Docs and Google ML Guide.