Study interactive :: Progress tools open in the Study Hub reader.

Introduction to ML Quick Reference

Quick lookup guide for ML concepts, algorithm selection, and workflow.

Table of Contents


Algorithm Selection Decision Tree

Need to predict something?Continuous value?Categorical value?No labels?REGRESSIONLinear? Linear RegressionNon-linear? Poly / RF /XGBoostNeed regularization? Ridge /Lasso / Elastic NetCLASSIFICATIONBinaryMulti-classInterpretability? LogReg / TreeBest performance? RF /XGBoost / NNSmall data? SVM / KNNLogReg multinomial / RF / NN /OvRUNSUPERVISEDGroups? ClusteringDimensions? PCA / t-SNE /UMAPAnomalies? Isolation Forest /One-Class SVM

ML Workflow Checklist

Problem Definition

Data Collection

Data Preparation

Feature Engineering

Model Training

Evaluation

Deployment

Monitoring


Problem Type Identification

Regression Problems

Characteristics:

Key Indicators:

Metrics:

Classification Problems

Characteristics:

Key Indicators:

Metrics:

Clustering Problems

Characteristics:

Key Indicators:

Metrics:


Quick Terminology Lookup

Data Terms

Term Definition
Feature Input variable (X)
Label/Target Output variable (y)
Training Data Data used to train model
Validation Data Data used to tune hyperparameters
Test Data Data used for final evaluation
Overfitting Model memorizes training data
Underfitting Model too simple, can't learn patterns

Model Terms

Term Definition
Algorithm Method to learn from data
Model Learned function that makes predictions
Hyperparameter Configuration set before training
Parameter Values learned during training
Epoch One pass through training data
Batch Subset of data processed together

Evaluation Terms

Term Definition
Accuracy Percentage of correct predictions
Precision Of positive predictions, how many correct
Recall Of actual positives, how many found
F1-Score Harmonic mean of precision and recall
ROC-AUC Area under ROC curve
Confusion Matrix Breakdown of predictions vs actual

Common Patterns and Anti-patterns

Good Patterns

# Pattern 1: Proper train/test split
from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

# Pattern 2: Scale features
from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)  # Don't fit on test!

# Pattern 3: Cross-validation
from sklearn.model_selection import cross_val_score

scores = cross_val_score(model, X_train, y_train, cv=5)
print(f"Mean CV score: {scores.mean():.3f}")

# Pattern 4: Evaluate on test set only once
model.fit(X_train, y_train)
test_score = model.score(X_test, y_test)

Anti-patterns

# Anti-pattern 1: Data leakage
# DON'T: Use future information
df['target'] = df['feature'].shift(-1)  # Using future data!

# Anti-pattern 2: Fitting on test data
# DON'T: Fit scaler on test data
scaler.fit(X_test)  # Wrong!

# Anti-pattern 3: Overfitting
# DON'T: Use too complex model without validation
model = ComplexModel(max_depth=1000)  # Will overfit!

# Anti-pattern 4: Testing multiple times
# DON'T: Evaluate on test set multiple times
for i in range(10):
    model = train_model()
    score = model.score(X_test, y_test)  # Wrong! Test set used multiple times

Quick Algorithm Reference

Regression Algorithms

Algorithm When to Use Pros Cons
Linear Regression Linear relationships Simple, interpretable Assumes linearity
Polynomial Regression Non-linear relationships Handles curves Can overfit
Random Forest General purpose Good performance Less interpretable
XGBoost Best performance needed Excellent performance Complex, slow

Classification Algorithms

Algorithm When to Use Pros Cons
Logistic Regression Baseline, interpretable Simple, fast Assumes linearity
Decision Tree Need interpretability Very interpretable Prone to overfitting
Random Forest General purpose Good performance Less interpretable
SVM Small-medium datasets Effective Slow on large data
KNN Local patterns Simple Slow prediction

Clustering Algorithms

Algorithm When to Use Pros Cons
K-Means Spherical clusters Fast, simple Need to specify k
Hierarchical Unknown number of clusters Visual dendrogram Slow on large data
DBSCAN Non-spherical clusters Finds outliers Sensitive to parameters

Common Mistakes to Avoid

  1. Data Leakage: Using future information to predict past
  2. Overfitting: Model too complex, memorizes training data
  3. Underfitting: Model too simple, can't learn patterns
  4. Wrong Metrics: Using accuracy for imbalanced data
  5. No Validation, not using validation set
  6. Test Set Contamination: Using test set multiple times
  7. Ignoring Baseline, not comparing with simple baseline
  8. No Documentation, not documenting experiments

Quick Tips

  1. Start Simple: Begin with simple models (linear/logistic regression)
  2. Use Baseline: Always compare with a simple baseline
  3. Validate Properly: Use cross-validation or hold-out validation
  4. Check for Overfitting: Compare train vs validation performance
  5. Use Appropriate Metrics: Choose metrics based on problem type
  6. Document Everything: Keep track of experiments and results
  7. Iterate: ML is iterative, improve based on results

Try next: Use this page while coding. Open the main guide when a line here is unclear.