← All mindmapsMAIN TOPIC · 04 / 14Machine Learning
Learning paradigms, algorithms, validation and evaluation
Explore full topic ↗ Readable revision notes (23 concepts)
The same content as the visual sheet, optimized for mobile and assistive technology.
01 · Learning paradigms
- Supervised: labelled data; regression/classification
- Unsupervised: clustering, dimensionality reduction
- Semi-supervised: few labels; RL: reward-driven policy
02 · Linear regression
- Predict continuous y: ŷ=b+wᵀx; OLS minimizes Σ(y−ŷ)².
- Closed form (XᵀX)⁻¹Xᵀy if full rank; otherwise use pseudoinverse or solver.
- Assumptions for classical inference: linear mean, independent errors, constant variance; normality for small-sample tests.
- Check residual patterns, VIF and MAE/RMSE; extrapolation is risky.
03 · Polynomial regression
- Expand x into powers or interactions; fit a linear model in expanded features.
- Degree increases flexibility and overfitting risk; scale and regularize features.
- Use CV to choose degree. Not the same as nonlinear-in-parameters regression.
04 · Logistic regression
- Binary p=1/(1+exp(−(wᵀx+b))); log odds linear in x.
- Optimize binary cross-entropy, not squared error; regularize coefficients.
- Decision boundary at p=0.5 by default; tune threshold to error costs.
- Multiclass: softmax or one-vs-rest depending on estimator.
05 · Decision tree (CART)
- Recursively choose split maximizing weighted impurity reduction.
- Gini=1−Σpᵢ²; entropy=−Σpᵢlog₂pᵢ; regression uses squared error.
- Leaf predicts majority/probability or mean; no feature scaling needed.
- Limit max_depth, min_samples_leaf; cost-complexity pruning reduces overfit.
06 · Random forest
- Train many trees on bootstrap samples; random feature subset per split.
- Average regression outputs or class probabilities; decorrelation lowers variance.
- Out-of-bag samples estimate performance when bootstrapping.
- Tune n_estimators, max_features, depth; less interpretable than one tree.
07 · Bagging vs boosting
- Bagging trains independent resamples and averages to reduce variance.
- Boosting builds additive learners sequentially to improve weak predictions.
- Bagging tolerates deep trees; boosting often uses shallow trees and shrinkage.
08 · AdaBoost & gradient boosting
- AdaBoost increases emphasis on misclassified examples; combines weighted learners.
- Gradient boosting fits weak learners to negative loss gradients.
- Fₘ(x)=Fₘ₋₁(x)+ηhₘ(x); tune learning rate, depth, number of trees.
09 · XGBoost / LightGBM / CatBoost
- XGBoost: regularized objective, second-order gradient approximation.
- LightGBM: histogram splits and leaf-wise growth; constrain leaves.
- CatBoost: ordered techniques reduce target leakage in categorical processing.
- Compare validation quality, memory, latency; no universal winner.
10 · Support vector machine
- Find maximum-margin separator; soft margin trades violation against margin.
- C controls penalty; kernel K(x,z) enables nonlinear boundaries.
- RBF γ controls locality; scale numeric features.
- Good for smaller high-dimensional data; training can be expensive at scale.
11 · K-nearest neighbors
- Find k nearest training samples; vote or average target.
- Euclidean d=√Σ(xᵢ−zᵢ)²; standardize and choose meaningful metric.
- Small k high variance; large k high bias; prediction cost grows with data.
- High dimensions reduce distance discrimination.
12 · Naive Bayes
- Choose class maximizing P(c)ΠP(xᵢ|c) under conditional independence.
- Gaussian for continuous features; multinomial for counts; Bernoulli for binary.
- Use smoothing to avoid zero likelihoods; sum log probabilities.
- Fast baseline for sparse text; correlated features can distort calibration.
13 · K-means clustering
- Choose k centroids; alternate assignment and mean recomputation.
- Minimize Σ‖xᵢ−μcᵢ‖²; use k-means++ and restarts.
- Scale data; favors compact Euclidean clusters; sensitive to outliers.
- Elbow and silhouette are heuristics, not proof of true cluster count.
14 · DBSCAN & hierarchical
- DBSCAN: eps-neighborhood + min_samples define core points; marks noise.
- Can detect nonconvex clusters; struggles with varying density.
- Agglomerative repeatedly merges clusters; linkage determines distance.
- Dendrogram cut chooses clusters; Ward minimizes within-cluster variance.
15 · PCA & dimensionality reduction
- Center X; project onto eigenvectors of covariance (or SVD of centered X).
- PCs orthogonal; eigenvalues quantify explained variance; scale when units differ.
- PCA is linear; t-SNE/UMAP useful for exploratory visualization.
- Fit only on training data; retain components using CV or explained variance.
16 · L1, L2 & elastic net
- Ridge: MSE+λΣw² shrinks coefficients; Lasso: MSE+λΣ|w| can produce zeros.
- Elastic net combines both penalties; standardize features for comparable shrinkage.
- Large λ may underfit; choose via CV. Do not penalize intercept unnecessarily.
17 · Bias–variance tradeoff
- Expected squared error = bias² + variance + irreducible noise (under standard setup).
- High bias: poor train and validation; high variance: train good, validation poor.
- More data/regularization can reduce variance; richer features may reduce bias.
18 · Confusion matrix & thresholds
- TP/TN correct; FP false alarm; FN missed positive.
- Precision=TP/(TP+FP); recall=TP/(TP+FN); specificity=TN/(TN+FP).
- F1=2PR/(P+R); accuracy unreliable for severe imbalance.
- Lower threshold often increases recall while reducing specificity.
19 · ROC, PR & calibration
- ROC plots TPR against FPR; AUC measures ranking across thresholds.
- PR curve emphasizes positive retrieval; useful on rare-positive tasks.
- Calibration asks whether predicted probabilities match observed frequency.
- Use Brier score and reliability plots; tune threshold on validation, not test.
20 · Regression evaluation
- MAE=mean|y−ŷ|; RMSE=√mean(y−ŷ)²; RMSE penalizes large errors.
- R²=1−SSE/SST; may be negative on unseen data; undefined for constant target without conventions.
- Compare naive baseline; inspect residuals by groups and time.
21 · Validation & tuning
- Random split for IID; stratified for classes; group split for shared entities.
- Time series: forward-only validation; nested CV separates tuning/evaluation.
- Grid/random/Bayesian search; fit preprocessing inside each fold.
- Avoid repeatedly selecting models using test scores.
22 · Feature engineering & imbalance
- Mean/median imputation, one-hot categorical encoding, standard/robust scaling.
- Fit transforms on train only; target encoding must avoid target leakage.
- SMOTE only in training fold; class weights or threshold tuning alternatives.
- Feature selection: filter, wrapper, embedded; report impact.
23 · Interpretability & selection
- Permutation importance measures validation score drop; correlated features complicate it.
- SHAP attributes individual predictions under a chosen background; not causal proof.
- Start with linear/logistic baseline, compare trees/ensembles for nonlinear tabular data.
- Track drift, calibration, failure slices and inference costs.
References & further study
Original schematics illustrate concepts, not measured data. Review these references for full derivations and implementation details.