How to use the Machine Learning Algorithms Cheat Sheet
- 1. Search or browseType what you want to do, or pick one section of the Machine Learning Algorithms cheat sheet.
- 2. CopyEvery entry has its own Copy button, so it goes straight into your editor or notes.
- 3. DownloadSave the whole Machine Learning Algorithms cheat sheet as plain text or Markdown for offline revision.
What's in it
Snippets assume you already have X (features) and y (labels), and the train/test split from the first snippet. The 32 snippets are organised into 8 sections: Workflow, Regression, Classification, Ensembles, Clustering, Dimensionality reduction, Evaluation, Choosing.
Every snippet was run with scikit-learn 1.x on generated sample data without errors.
Example
A sensible first project on a table of customer data: split with train_test_split(..., stratify=y), fit a LogisticRegression baseline, then try HistGradientBoostingClassifier. Compare them with cross_val_score(..., cv=5, scoring="f1") rather than one lucky split. If the boosted model scores clearly higher across all five folds, the extra complexity has earned its place; if not, keep the simpler model.
Tips for using it
- Always start with a simple baseline; it tells you whether a fancy model is really helping.
- Scale features for k-NN, SVM, logistic regression and k-means. Tree models don't need it.
- Never fit a scaler or encoder on the whole dataset before splitting; that leaks test information into training.
A quick look, one entry per section
- Workflow:
from sklearn.model_selection import train_test_split(hold back 20% for testing; stratify keeps class shares the same) - Regression:
from sklearn.linear_model import LinearRegression(linear regression: a straight-line fit; fast and easy to explain) - Classification:
from sklearn.linear_model import LogisticRegression(logistic regression: a probability for each class; a strong baseline) - Ensembles:
from sklearn.ensemble import RandomForestClassifier(random forest: many trees on random samples, then a vote) - Clustering:
from sklearn.cluster import KMeans(k-means: k round groups; plot inertia for several k (elbow method)) - Dimensionality reduction:
from sklearn.decomposition import PCA(pCA: fewer features that keep most of the variance) - Evaluation:
from sklearn.metrics import accuracy_score, f1_score(accuracy and F1 (prefer F1 when classes are imbalanced)) - Choosing:
# Numbers to predict → LinearRegression first, then RandomForestRegressor / gradient boosting(rule of thumb for regression: start simple, then try tree ensembles)
Search the box above for the rest of the Machine Learning Algorithms entries, or download the full sheet.
Frequently asked questions
Which scikit-learn version?
The snippets were run with scikit-learn 1.x on sample data. HistGradientBoosting has been stable since 1.0.
Does it cover deep learning?
No. Neural networks need PyTorch or TensorFlow; this sheet focuses on classic ML.
Is the Machine Learning Algorithms cheat sheet free?
Yes. You can search, read and copy every entry in the Machine Learning Algorithms cheat sheet without signing up. The first time you download it, we ask once for your name and WhatsApp number; after that downloads and every other Uncodemy tool open straight away.