Machine Learning Cheat Sheet
Algorithms · metrics · pipelines
Supervised vs unsupervised, top algorithms, evaluation metrics, hyperparameter tuning, and pipeline visuals.
PDF quick reference
MachineCheat sheet
- Sections
- 3
- Snippets
- 4
- Pages
- 3
01
Algorithm selector
Regression → Linear Reg, Random Forest, XGBoostClassification → Logistic Reg, RF, XGBoost, SVMClustering → KMeans, DBSCAN, HierarchicalAnomaly → Isolation Forest, One-class SVMNLP → Transformers (BERT, GPT family)
02
Evaluation metrics
Accuracy = (TP + TN) / totalPrecision = TP / (TP + FP)Recall = TP / (TP + FN)F1 = 2 * P * R / (P + R)ROC-AUC classifier vs random
MAE mean(|y - ŷ|)MSE mean((y - ŷ)²)RMSE √MSER² 1 - SS_res / SS_tot
03
Sklearn pipeline
from sklearn.pipeline import Pipelinefrom sklearn.preprocessing import StandardScalerfrom sklearn.linear_model import LogisticRegressionpipe = Pipeline([("scaler", StandardScaler()),("clf", LogisticRegression())])pipe.fit(X_train, y_train)pipe.score(X_test, y_test)
