Concepts 🚀 Project 🧮 Labs
🧮 Labs / ML Advanced / Model selection — which algorithm for which problem?

Model selection — which algorithm for which problem?

Not 'try RandomForest'. A decision framework: data size, feature type, interpretability need, linearity assumption. Pick the RIGHT model.

script.py v3.1
Python output click Run to execute
Click "Run" to execute the code on the left.
The output will appear here.
🧠 How it works

Model selection = matching algorithm to problem. 5 questions: Q1: Regression (continuous target) vs Classification (categorical target). Q2: Data size. <100 = linear models. 100-10k = anything. >100k = avoid KNN/SVM. Q3: Linear vs non-linear. Plot scatter. Linear line → LinearRegression. Curve → trees/SVM. Q4: Interpretability. Medical/legal/finance → linear/tree. Competition → XGBoost/neural net. Q5: Feature count. <50 = anything. 50-1000 = linear/trees. >1000 = linear/neural/reduce dims. RULE OF THUMB: Start with LinearRegression/LogisticRegression (baseline). Try RandomForest (handles non-linearity, no scaling). If accuracy matters most: XGBoost/LightGBM. If data is images/text/audio: neural nets. If data is small + high-dim: SVM. If you need interpretability: DecisionTree or linear. NEVER start with neural nets on tabular data — XGBoost almost always wins.

✏️ Try these changes
  • Change n_samples from 500 to 50
    → linear models will win — small data favors low-variance models
  • Change n_features from 10 to 100
    → KNN will do worse — curse of dimensionality
  • Change noise from 15 to 50
    → all models do worse — harder problem
  • Add make_classification + compare LogisticRegression vs RandomForestClassifier
    → classification version of the same benchmark