Scikit Learn Estimator Cheat Sheet Choosing The Ri
You’ve cleaned the data. You’ve split it into training and test sets. You’ve even made yourself a fresh cup of coffee. And now you’re staring at the scikit-learn API reference—fifty-plus estimators staring back—and you have absolutely no idea which one to import.
You’re not missing knowledge. You’re missing a decision structure. That’s exactly what this article gives you: a plain-English walk through the official scikit-learn algorithm cheat sheet, so the next time you hit that moment you’ll trace your own dataset through a few simple questions and land on a concrete starting point.
The single best resource for this is the official scikit-learn flowchart. It encodes the decision logic the library’s own maintainers recommend, and it’s what we’ll translate here—branch by branch, question by question—with runnable code at every step.
This isn’t a list of algorithms. It’s a decision tree you can walk through with your data in mind, where every fork is explained in terms of what your data actually looks like.
The Four Questions Every Estimator Choice Starts With
Before we touch a single algorithm name, we need to answer four questions about your problem. These are the top-level branches of the scikit-learn flowchart, and they determine which universe of estimators you’re even shopping in.
Question 1: Do you have labeled data? If yes, you’re in supervised learning—either classification or regression. If no, you’re in unsupervised learning—either clustering or dimensionality reduction. This is the single most important fork in the road. If you’re trying to predict house prices (you have the historical sale prices), you’re supervised. If you’re trying to group customers into segments without any pre-existing labels, you’re unsupervised.
Question 2: If supervised, are you predicting a category or a quantity? Category means classification. Quantity means regression. This sounds obvious, but real-world problems blur the line. Predicting a star rating (1–5) is ordinal—it’s classification, not regression, even though the labels look like numbers. If the thing you’re predicting has a meaningful order but the distances between values aren’t consistent, treat it as classification.
Question 3: If unsupervised, are you looking for groups or structure? Groups mean clustering. Structure means dimensionality reduction. Again, simple in theory, but the cheat sheet forces you to be explicit about your goal before you reach for an algorithm. “I want to see if my customers fall into natural segments” is clustering. “I want to compress my 500 features into 10 that still capture most of the variance” is dimensionality reduction.
Question 4: How many samples do you have? The flowchart uses <100K vs. ≥100K as a key branch point for both classification and regression. This isn’t arbitrary—it’s the approximate threshold where linear models with stochastic optimization (like SGDClassifier) start to dominate in scikit-learn’s own benchmarks. Below 100K samples, you can afford fancier models; above it, you want models that train fast and scale linearly.
Answer those four questions, and you’ve already narrowed the field from fifty-plus estimators to about five. Now let’s walk each branch.
Classification: Your Data Has Labels, and You’re Predicting a Category
You’ve got labeled data, and the thing you’re predicting is a category—spam or not spam, churn or no churn, disease A vs. disease B. Now the flowchart asks a series of questions about what your data looks like.
The text-data fork
Here’s the first question the classification branch asks: are your features raw text? If you’re working with tweets, product reviews, or support tickets—and you haven’t already converted them to numerical vectors—the flowchart sends you to Kernel Approximation before any other classifier. In plain English: text isn’t numbers, and most classifiers expect numbers. You need to vectorize first. We’ll cover that in a future pipeline article; for now, the key takeaway is that text data takes a detour through feature extraction before it hits any classifier.
The <100K samples path: start simple, escalate complexity
If you have fewer than 100,000 samples, the flowchart recommends a specific escalation path. This is the exact opposite of what most beginners do—they reach for the fanciest model first. The cheat sheet says: start simple, and only escalate if the simple model underperforms.
Step 1: Linear SVC or KNeighbors. LinearSVC is a linear classifier that tries to draw a straight line (or hyperplane) to separate your classes. It’s fast, it’s interpretable, and it’s surprisingly effective on high-dimensional data like text. KNeighborsClassifier is even simpler—it classifies a new point by looking at the labels of its k nearest neighbors in the training set. If your data has clear, well-separated clusters, KNeighbors can work beautifully.
Step 2: If that doesn’t work, try SVC with an RBF kernel. The RBF kernel lets the SVM draw curved decision boundaries instead of straight lines. It’s more flexible than LinearSVC, but it’s also slower and more prone to overfitting if you don’t tune the C and gamma parameters. This is the “my data isn’t linearly separable” fallback.
Step 3: If that still doesn’t work, try an Ensemble Classifier. Random Forest or Gradient Boosting. These are the heavy hitters—they combine many weak models (usually decision trees) into one strong predictor. They can capture complex nonlinear relationships and interactions between features, but they’re slower to train and harder to interpret. We’ll dig into the Random Forest vs. Gradient Boosting decision later in this article.
Let’s see this “start simple, escalate” pattern in code:
# Self-contained: imports, data generation, train/test split, and model fitting
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.svm import LinearSVC, SVC
from sklearn.ensemble import RandomForestClassifier
# Generate a synthetic classification dataset with 5,000 samples
X, y = make_classification(n_samples=5000, n_features=20, n_informative=10,
n_redundant=5, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Step 1: Start simple with LinearSVC
linear_svc = LinearSVC(dual='auto', max_iter=5000, random_state=42)
linear_svc.fit(X_train, y_train)
linear_score = linear_svc.score(X_test, y_test)
print(f"LinearSVC test accuracy: {linear_score:.3f}")
# If LinearSVC underperforms (say, below 0.85), escalate to SVC with RBF kernel
if linear_score < 0.85:
print("LinearSVC underperformed—escalating to SVC with RBF kernel...")
svc_rbf = SVC(kernel='rbf', random_state=42)
svc_rbf.fit(X_train, y_train)
svc_score = svc_rbf.score(X_test, y_test)
print(f"SVC (RBF) test accuracy: {svc_score:.3f}")
# If SVC still underperforms, escalate to Random Forest
if svc_score < 0.85:
print("SVC still underperformed—escalating to Random Forest...")
rf = RandomForestClassifier(n_estimators=100, random_state=42)
rf.fit(X_train, y_train)
rf_score = rf.score(X_test, y_test)
print(f"Random Forest test accuracy: {rf_score:.3f}")
else:
print("LinearSVC performed well—no need to escalate.")
What this code does: it starts with the simplest reasonable model (LinearSVC), checks its performance, and only escalates to more complex models if the simple one underperforms. The threshold of 0.85 is arbitrary—you’d set it based on your problem’s requirements. The key pattern is: don’t reach for the ensemble until you’ve tried the linear model.
The ≥100K samples path: linear models with stochastic optimization
When you cross the 100K-sample threshold, the game changes. You want models that train fast and scale well. The flowchart recommends:
Step 1: SGDClassifier or LinearSVC. SGDClassifier with a linear kernel uses stochastic gradient descent—it updates its weights one sample (or mini-batch) at a time, which means it can handle datasets that don’t fit in memory. LinearSVC uses a different solver (liblinear) that’s also efficient at scale.
Step 2: If that doesn’t work, try Kernel Approximation + SGDClassifier. Kernel Approximation approximates the RBF kernel without the full computational cost, letting you get nonlinear decision boundaries with the scalability of a linear model. It’s a clever trick: you transform your features into a higher-dimensional space where the data might be linearly separable, then apply a linear classifier.
Step 3: If that still doesn’t work, try Naive Bayes. At this scale, Naive Bayes is specifically recommended for text-like features where the independence assumption (each feature contributes independently to the class probability) is least violated. MultinomialNB is the go-to for word counts; GaussianNB for continuous features.
Here’s the thing about the “TRY NEXT” arrows on the flowchart: they’re the most honest part of the whole document. They encode the reality that no algorithm is guaranteed to work on your data. The cheat sheet is a starting-point heuristic, not a promise. If your first choice underperforms, you try the next one—not because you failed, but because that’s how the process works.
Regression: Your Data Has Labels, and You’re Predicting a Quantity
The regression branch mirrors the classification branch in structure—same sample-size split—but the estimator recommendations are different, and the “TRY NEXT” chain is shorter. Regression problems tend to be more forgiving of linear models, so the cheat sheet keeps you in the linear family longer.
The <100K path: Ridge, Lasso, or ElasticNet—and why the choice matters
When you have fewer than 100,000 samples, the flowchart points you to regularized linear regression first. But “regularized linear regression” is three different algorithms, and the choice between them encodes assumptions about your features.
Ridge regression (L2 regularization) shrinks coefficients toward zero but keeps all features in the model. It’s the default starting point when you believe most of your features have at least some predictive value, even if small. Ridge handles multicollinearity (correlated features) gracefully by spreading the weight among them.
Lasso regression (L1 regularization) can zero out coefficients entirely. If a feature doesn’t help predict the target, Lasso will set its coefficient to exactly zero—effectively performing feature selection. This is powerful when you have many features but suspect only a few matter. The catch: if you have a group of highly correlated features, Lasso will pick one arbitrarily and zero out the rest. That might be fine for prediction, but it can be misleading for interpretation.
ElasticNet combines L1 and L2 regularization. The scikit-learn docs explicitly recommend it “when there are multiple features that are correlated with one another. Lasso is likely to pick one of these at random, while elastic-net is likely to pick both.” This is the single most actionable tie-breaker in the regression section—and it’s one most cheat sheets get vague about.
Let’s make this concrete with code:
# Self-contained: imports, data generation, and model fitting
import numpy as np
from sklearn.linear_model import Ridge, Lasso, ElasticNet
from sklearn.model_selection import train_test_split
# Generate synthetic data with correlated features
np.random.seed(42)
n_samples = 200
X_base = np.random.randn(n_samples, 1)
# Create 5 features that are all correlated with the base feature
X = np.hstack([X_base + 0.3 * np.random.randn(n_samples, 1) for _ in range(5)])
# True relationship: only features 0 and 1 matter
y = 3 * X[:, 0] + 2 * X[:, 1] + 0.5 * np.random.randn(n_samples)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Fit Ridge, Lasso, and ElasticNet
ridge = Ridge(alpha=1.0)
ridge.fit(X_train, y_train)
print("Ridge coefficients (all features kept):")
print(np.round(ridge.coef_, 3))
lasso = Lasso(alpha=0.1, max_iter=5000)
lasso.fit(X_train, y_train)
print("\nLasso coefficients (some zeroed out):")
print(np.round(lasso.coef_, 3))
elastic = ElasticNet(alpha=0.1, l1_ratio=0.5, max_iter=5000)
elastic.fit(X_train, y_train)
print("\nElasticNet coefficients (compromise between Ridge and Lasso):")
print(np.round(elastic.coef_, 3))
Look at the output. Ridge keeps all five coefficients nonzero—it shrinks them toward zero but doesn’t eliminate any. Lasso, depending on the alpha strength, may zero out some of the correlated features entirely—it picks winners and losers. ElasticNet finds a middle ground: it shrinks the less-important features more aggressively than Ridge but doesn’t necessarily zero them out completely. This is what “feature selection vs. coefficient shrinkage” looks like in practice.
The fallback path: SVR and Ensembles
If linear models underperform, the flowchart sends you to SVR with an RBF kernel (for small data) or an Ensemble Regressor (Random Forest or Gradient Boosting). SVR is the regression cousin of SVC—it can model nonlinear relationships, but it scales poorly. The underlying quadratic programming solver scales between O(n_features × n_samples²) and O(n_features × n_samples³), making it impractical beyond about 100K samples. That’s why SVR appears in the small-data path but not the large-data path.
The ≥100K path: SGDRegressor and Kernel Approximation
At scale, you start with SGDRegressor—stochastic gradient descent for linear regression. If that underperforms, you try Kernel Approximation + SGDRegressor to get nonlinearity with linear-model scalability. The pattern is the same as classification: at scale, you want linear models with stochastic optimization.
Clustering: No Labels, Just Looking for Groups
The unsupervised branch is fundamentally different. You’re not predicting anything—you’re discovering structure. The decision tree isn’t about sample size; it’s about what kind of clusters you expect your data to have, and whether you know how many clusters there are.
The question the flowchart doesn’t ask (but should)
Do you know how many clusters you’re looking for? If yes, your starting points are KMeans or Spectral Clustering. If no, your starting points are DBSCAN or HDBSCAN. This is the single most important clustering decision, and it’s the one beginners get wrong most often.
KMeans is the default for a reason: it’s fast, simple, and works well when your clusters are roughly spherical and similar in size. But it “responds poorly to elongated clusters”—if your data has banana-shaped groups, KMeans will slice them into circles and give you nonsense. KMeans also requires you to specify n_clusters in advance. If you guess wrong, the results can be misleading.
DBSCAN defines clusters as dense regions separated by sparse regions. It can find clusters of arbitrary shape, and it automatically identifies noise points (samples that don’t belong to any cluster). The trade-off: you need to set eps (the neighborhood radius), and it struggles with clusters of varying density—a tight cluster and a loose cluster in the same dataset will confuse it.
HDBSCAN is the modern upgrade. It’s DBSCAN without the eps parameter—it finds clusters across varying density levels automatically. It’s now a first-class estimator in scikit-learn, and it’s the first-choice recommendation for most real-world clustering problems where you don’t know the cluster count.
Spectral Clustering fills a specific niche: it can find clusters that aren’t convex (like concentric circles), but it requires you to specify the number of clusters in advance. It’s the right choice when KMeans fails on non-spherical data but you do know the cluster count.
Let’s see the KMeans-vs-DBSCAN distinction on data where the cluster shape assumption really matters:
# Self-contained: imports, data generation, clustering, and visualization
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_moons
from sklearn.cluster import KMeans, DBSCAN
from sklearn.preprocessing import StandardScaler
# Generate moon-shaped data (non-spherical clusters)
X, _ = make_moons(n_samples=300, noise=0.08, random_state=42)
X = StandardScaler().fit_transform(X)
# KMeans: assumes spherical clusters, must specify n_clusters
kmeans = KMeans(n_clusters=2, random_state=42, n_init=10)
kmeans_labels = kmeans.fit_predict(X)
# DBSCAN: finds dense regions, doesn't need n_clusters
dbscan = DBSCAN(eps=0.3, min_samples=5)
dbscan_labels = dbscan.fit_predict(X)
# Plot side by side
fig, axes = plt.subplots(1, 2, figsize=(12, 5))
axes[0].scatter(X[:, 0], X[:, 1], c=kmeans_labels, cmap='viridis', s=30, edgecolor='k')
axes[0].set_title("KMeans: forces spherical clusters\n(cuts the moons in half)")
axes[0].set_xlabel("Feature 1")
axes[0].set_ylabel("Feature 2")
axes[1].scatter(X[:, 0], X[:, 1], c=dbscan_labels, cmap='viridis', s=30, edgecolor='k')
axes[1].set_title("DBSCAN: finds arbitrary-shaped clusters\n(recovers the moons)")
axes[1].set_xlabel("Feature 1")
axes[1].set_ylabel("Feature 2")
plt.tight_layout()
plt.show()
What you’ll see: KMeans slices the two moon-shaped clusters in half—it draws a straight-line boundary through the middle because it assumes clusters are convex blobs. DBSCAN, by contrast, follows the density and correctly separates the two crescents. This is the “cluster shape assumption” made concrete. If your data looks like moons, KMeans will lie to you.
Dimensionality Reduction: No Labels, Just Looking for Structure in Fewer Dimensions
The dimensionality-reduction branch is the shortest in the flowchart, but it’s also the one where the “why” matters most. You’re not just reducing dimensions—you’re choosing between preserving global structure, preserving local neighborhoods, or maximizing class separability.
The goal-driven split
The flowchart asks: are you reducing dimensions for visualization (2D or 3D) or for feature extraction/preprocessing? This is a goal-driven split, not a data-driven one.
For visualization: t-SNE or PCA. t-SNE is the visualization specialist. It preserves local neighborhoods at the expense of global structure. Two points that are close in the original high-dimensional space will be close in the t-SNE plot—but the distances between clusters are meaningless. This is the hardest part for beginners to internalize: you can’t read cluster sizes or distances off a t-SNE plot. A large gap between two clusters in a t-SNE plot doesn’t mean they’re far apart in the original space; a small cluster in the plot doesn’t mean it’s a small cluster in the data.
For feature extraction: PCA or Truncated SVD. PCA finds the directions of maximum variance in your data and projects onto them. It’s fast, deterministic, and preserves global structure—but it can’t capture nonlinear relationships, and it’s sensitive to feature scaling. Truncated SVD is PCA for sparse data: it works on the raw term-document matrix without densifying it, making it the go-to for text data (often paired with TF-IDF vectorization).
LDA (Linear Discriminant Analysis) is the supervised option not on the main flowchart but worth knowing: it reduces dimensions while maximizing class separability. If you have labels and you’re reducing dimensions specifically to improve classification, LDA is your choice.
Let’s see the PCA vs. t-SNE distinction on data with nonlinear structure:
# Self-contained: imports, data generation, dimensionality reduction, and visualization
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_swiss_roll
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
# Generate a Swiss roll (3D data with nonlinear structure)
X, color = make_swiss_roll(n_samples=1000, noise=0.1, random_state=42)
# PCA: preserves global variance structure
pca = PCA(n_components=2)
X_pca = pca.fit_transform(X)
# t-SNE: preserves local neighborhoods
tsne = TSNE(n_components=2, random_state=42, perplexity=30)
X_tsne = tsne.fit_transform(X)
# Plot side by side
fig, axes = plt.subplots(1, 2, figsize=(12, 5))
sc1 = axes[0].scatter(X_pca[:, 0], X_pca[:, 1], c=color, cmap='Spectral', s=10)
axes[0].set_title("PCA: preserves global structure\n(notice the overall spread)")
axes[0].set_xlabel("PC 1")
axes[0].set_ylabel("PC 2")
sc2 = axes[1].scatter(X_tsne[:, 0], X_tsne[:, 1], c=color, cmap='Spectral', s=10)
axes[1].set_title("t-SNE: preserves local neighborhoods\n(notice the tight clusters)")
axes[1].set_xlabel("t-SNE 1")
axes[1].set_ylabel("t-SNE 2")
plt.tight_layout()
plt.show()
Look at the PCA plot: you’ll see the Swiss roll “unfurled” in a way that preserves the overall shape—points that were far apart in 3D are still far apart in 2D. Now look at the t-SNE plot: you’ll see tight, well-separated clusters, but the distances between those clusters are not interpretable. t-SNE broke the global structure to preserve the local neighborhoods. Neither is “better”—they serve different goals.
The Ensemble Decision: Random Forest vs. Gradient Boosting
Both classification and regression branches recommend “Ensemble Classifiers” or “Ensemble Regressors” as a fallback. But “ensemble” is a family, not a single algorithm—and the choice between bagging (Random Forest) and boosting (Gradient Boosting) encodes fundamentally different assumptions about your data’s noise level.
Random Forest (bagging) builds many deep, individually-overfit trees on random subsets of the data, then averages their predictions. Think of it like asking 100 overconfident experts and taking the majority vote. Each expert might be wrong in their own idiosyncratic way, but the average of their opinions is usually right. Random Forest is robust to noisy data and rarely overfits catastrophically—you can throw hundreds of trees at a problem and it’ll usually just plateau rather than get worse.
Gradient Boosting (boosting) builds shallow, individually-underfit trees sequentially—each new tree tries to correct the errors of the previous ensemble. Think of it like a student who keeps studying the questions they got wrong. Boosting can achieve higher accuracy than bagging, but it’s more prone to overfitting if the data is noisy or if you let it run too many iterations. It’s also more sensitive to hyperparameters—the learning rate and number of estimators need to be tuned together.
The practical tie-breaker: if your data has a lot of label noise (mislabeled examples, inherently stochastic outcomes), Random Forest’s averaging is more forgiving. If your data is clean and you need every last point of accuracy, Gradient Boosting—especially HistGradientBoostingClassifier—will usually win, but you’ll need to tune it carefully.
HistGradientBoosting is the modern, faster variant: it bins continuous features into histograms (similar to LightGBM) and can handle missing values natively. It’s now the recommended boosting implementation in scikit-learn for most use cases.
Let’s see the trade-off in code:
# Self-contained: imports, data generation, model fitting, and cross-validation
from sklearn.datasets import make_classification
from sklearn.model_selection import cross_val_score
from sklearn.ensemble import RandomForestClassifier, HistGradientBoostingClassifier
import numpy as np
# Generate a clean classification dataset
X, y = make_classification(n_samples=3000, n_features=20, n_informative=10,
n_redundant=5, random_state=42)
# Random Forest: robust out of the box
rf = RandomForestClassifier(n_estimators=100, random_state=42)
rf_scores = cross_val_score(rf, X, y, cv=5)
print(f"Random Forest CV accuracy: {rf_scores.mean():.3f} (+/- {rf_scores.std():.3f})")
# HistGradientBoosting: can achieve higher accuracy with tuning
hgb = HistGradientBoostingClassifier(max_iter=100, random_state=42)
hgb_scores = cross_val_score(hgb, X, y, cv=5)
print(f"HistGradientBoosting CV accuracy: {hgb_scores.mean():.3f} (+/- {hgb_scores.std():.3f})")
On clean data, you’ll often see HistGradientBoosting edge out RandomForest by a percentage point or two. But notice the standard deviation of the cross-validation scores—if the boosting model has higher variance across folds, that’s a sign it might be overfitting to the quirks of individual training splits. Random Forest’s scores tend to be more stable.
The Hardest Part: You Still Have to Validate Your Choice
The cheat sheet gets you to an estimator name. It does not tell you whether that estimator actually works on your data. The “TRY NEXT” arrows exist for a reason: no algorithm is guaranteed to work. The cheat sheet is a starting-point heuristic, and the only way to know if it worked is to evaluate on held-out data.
Cross-validation is the standard tool. Split your data into k folds, train on k-1 and test on the held-out fold, repeat k times, and average the scores. This gives you a more reliable estimate of generalization performance than a single train/test split—a single split might get lucky (or unlucky) with how the data happened to fall.
StratifiedKFold is essential for classification. It preserves the class distribution in each fold, preventing the case where a rare class ends up entirely in the test set and your evaluation becomes meaningless. If you’re classifying diseases and only 5% of your samples are positive, a naive k-fold split might put all the positive samples in one fold—and your model would look like it’s 95% accurate while never actually learning to detect the disease.
The hidden danger: if you use cross-validation to tune hyperparameters, you’re leaking information from the test folds into your model selection. You try ten different C values for your SVM, pick the one with the best cross-val score, and report that score as your model’s performance. But you just used the test folds to choose the hyperparameter—the score is optimistically biased. The fix is nested cross-validation (an outer loop for evaluation, an inner loop for hyperparameter tuning) or, more practically, a single held-out test set that you never touch during tuning.
Let’s see why stratified splitting matters:
# Self-contained: imports, data generation, and cross-validation comparison
from sklearn.datasets import make_classification
from sklearn.model_selection import cross_val_score, StratifiedKFold, KFold
from sklearn.linear_model import LogisticRegression
import numpy as np
# Generate an imbalanced classification dataset
X, y = make_classification(n_samples=1000, n_features=10, weights=[0.9, 0.1],
random_state=42)
print(f"Class distribution: {np.bincount(y)}") # ~900 of class 0, ~100 of class 1
model = LogisticRegression(max_iter=1000)
# Naive KFold: folds might not preserve class balance
kf = KFold(n_splits=5, shuffle=True, random_state=42)
kf_scores = cross_val_score(model, X, y, cv=kf, scoring='f1')
print(f"Naive KFold F1 scores: {kf_scores}")
print(f"Mean F1: {kf_scores.mean():.3f} (+/- {kf_scores.std():.3f})")
# StratifiedKFold: preserves class balance in each fold
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
skf_scores = cross_val_score(model, X, y, cv=skf, scoring='f1')
print(f"\nStratifiedKFold F1 scores: {skf_scores}")
print(f"Mean F1: {skf_scores.mean():.3f} (+/- {skf_scores.std():.3f})")
Look at the standard deviation of the scores. The naive KFold will often show much higher variance across folds—one fold might have zero positive samples and produce an F1 score of 0, while another fold has all the positives and scores perfectly. StratifiedKFold keeps the scores stable and trustworthy. The standard deviation matters because high variance across folds means your estimator choice might be unstable—it works well on some subsets of your data and poorly on others.
The Cheat Sheet in One Table
Here’s the entire decision tree synthesized into a single reference table. The prose walkthrough is for understanding; this table is for quick lookup when you’re staring at your screen and just need to know what to import.
| Goal | Data Shape | Start Here | Fallback (if underperforms) |
|---|---|---|---|
| Classification | Raw text features | Kernel Approximation + SGDClassifier | — |
| Classification | <100K samples | LinearSVC or KNeighbors | SVC (RBF) → Ensemble |
| Classification | ≥100K samples | SGDClassifier or LinearSVC | Kernel Approx + SGD → Naive Bayes |
| Regression | <100K samples | Ridge / Lasso / ElasticNet | SVR (RBF) → Ensemble |
| Regression | ≥100K samples | SGDRegressor | Kernel Approx + SGDRegressor |
| Clustering | Known k, spherical | KMeans | Spectral Clustering |
| Clustering | Known k, non-convex | Spectral Clustering | — |
| Clustering | Unknown k | DBSCAN | HDBSCAN |
| Dim. Reduction | Visualization (2D/3D) | t-SNE | PCA |
| Dim. Reduction | Feature extraction (dense) | PCA | — |
| Dim. Reduction | Feature extraction (sparse) | Truncated SVD | — |
| Dim. Reduction | Supervised (has labels) | LDA | — |
This table is not a replacement for the flowchart—it’s a compressed reference. The flowchart encodes the decision logic; the table encodes the resulting recommendations. When in doubt, trace the flowchart. When you just need a reminder, use the table.
What We Learned—and What’s Next
The scikit-learn estimator cheat sheet is a decision tree, not a menu. It asks questions about your data—labeled or unlabeled? category or quantity? how many samples? what kind of clusters?—and routes you to a starting-point estimator based on your answers.
The four most important decisions you’ll make: (1) supervised vs. unsupervised, (2) classification vs. regression, (3) sample size above or below ~100K, and (4) for clustering, whether you know the cluster count and what shape you expect.
The “TRY NEXT” arrows are the most honest part of the flowchart. No algorithm is guaranteed to work. The cheat sheet is a heuristic, not a promise. The only way to know if you chose right is to validate—and cross-validation, especially stratified, is the tool that makes your choice verifiable rather than guesswork.
Next in the series: we’ll take one of these estimator paths—likely the classification branch—and walk through the full pipeline. From data loading through feature preprocessing, estimator fitting, hyperparameter tuning, and evaluation, with heavily annotated code at every step. You’ll see how the estimator choice you made here plugs into a real, end-to-end workflow.
Check Your Understanding
Remember: What are the four top-level questions the scikit-learn flowchart asks before recommending an estimator?
Understand: Why does the flowchart use ~100K samples as a branch point? What changes about which models are practical above that threshold?
Apply: You have 20,000 labeled samples and you’re predicting whether a customer will churn (yes/no). Your features are numerical (usage metrics, account age, etc.). Walk through the decision tree and name the first estimator you’d try.
Analyze: You ran KMeans on a dataset and the clusters look wrong—the algorithm is splitting what you can visually see is one continuous group into multiple pieces. What assumption is KMeans making about your clusters, and which alternative should you try?
Evaluate: A colleague reports a 99% cross-validation score on a classification problem with 1,000 samples and 50 features. You notice they used regular KFold, not StratifiedKFold, and the dataset has only 5% positive samples. Why should you be skeptical of that 99% score?
Create: Design a small experiment: generate a synthetic dataset with 500 samples and two features where the classes are concentric circles (use make_circles from sklearn). Try LinearSVC, SVC with RBF kernel, and RandomForestClassifier. Which one performs best, and why does the decision tree’s “start simple, escalate” logic hold (or not hold) on this data?
Apply What You Learned
Deliverable: A short paragraph (or code comment) that says: “My problem is [supervised classification] with [8,500] samples. The flowchart recommends starting with [LinearSVC]. My 5-fold stratified cross-validation accuracy is [0.87]. I [would / would not] escalate to [SVC with RBF kernel] because [reason].”
Self-check rubric: Did you correctly identify supervised vs. unsupervised? Did you check your sample count against the 100K threshold? Did you use stratified cross-validation if it’s a classification problem? Did you actually follow the “TRY NEXT” logic rather than jumping straight to an ensemble?
Related articles
- Explainability Under review
Machine Learning In Robotics Where Classical Contr
Let's start with the simplest classical controller: PID. The name stands for Proportional-Integral-Derivative, but you don't need to remember that. Here's what it actually does:
- Explainability Under review
SHAP Values: Why Your Model Predicted That
Learn to use SHAP values to explain individual model predictions, see which features drove each decision, and uncover hidden bias using Python and force plots.
- Explainability Under review
LIME vs. SHAP: Choosing the Right 'Translator' for Your Black-Box Models
Learn how LIME's fast local perturbations and SHAP's game-theoretic Shapley values explain black-box model predictions, and when to use each for your projects.
- Python Engineering Under review
Reinforcement Learning Algorithms Reference Which
Before we name a single algorithm, we need to name the axes that separate them. Otherwise, you’re memorizing names without knowing why they differ—like learning the names of every screwdriver without knowing whether your screw is flathead or Phillips. Let’s fix that.
Looking for something else?
Search every article by title, summary or topic.