Classification (Advanced)
Beyond decision trees, Bayes, and k-NN, several powerful classifiers handle complex, non-linear, and high-dimensional boundaries.
1. Support Vector Machines (SVM)
Margin and Linear Separability
- Given two classes, an SVM finds the optimal separating hyperplane that maximizes the margin (distance to the nearest points of each class, the support vectors).
- Decision function:
; predict class by .
Hard vs Soft Margin
- Hard margin: requires perfect linear separation (rare in practice).
- Soft margin (C-SVM): allows some misclassified/in-margin points via slack variables
: subject to . trades off margin width vs. training errors: large ⇒ less tolerance (risk overfitting); small ⇒ wider margin (risk underfitting).
The Kernel Trick
- Map data into a higher-dimensional feature space
where it is linearly separable, without computing explicitly — use a kernel . - Common kernels:
- Linear:
- Polynomial:
- RBF / Gaussian:
, - Sigmoid:
- Linear:
- Decision is expressed via dual variables
(only support vectors have ):
| Pros | Cons |
|---|---|
| effective in high-D, robust to overfitting (margin) | choice of kernel & |
| works well with clear margin | slow on very large data ( |
| memory efficient (only SVs) | less interpretable |
2. Artificial Neural Networks (Backpropagation)
Perceptron & Multi-Layer Network
- A neuron:
, where is an activation (sigmoid, tanh, ReLU). - MLP (multi-layer perceptron): input → hidden layer(s) → output; can approximate any continuous function (universal approximation).
Backpropagation (Training)
Goal: minimize error
initialize weights randomly (small);
repeat:
for each training example:
forward pass: compute outputs o;
compute error δ at output: δ_out = (t - o)·σ'(net);
backpropagate: δ_h = σ'(net_h)·Σ w·δ_out;
update weights: w ← w + η·δ·x; (η = learning rate)
until convergence;- Learning rate
: too large ⇒ oscillate/diverge; too small ⇒ slow. - Momentum adds a fraction of the previous update to smooth.
- Overfitting: use early stopping (watch validation error), weight decay (
regularization), dropout.
| Pros | Cons |
|---|---|
| learns complex non-linear boundaries | "black box", hard to interpret |
| good for high-dim, noisy data | many hyperparameters, slow training |
| scales with GPU | needs lots of data |
3. Ensemble Methods
Idea: combine multiple base learners ("weak learners") to get a strong learner with lower variance/bias and better generalization.
Bagging (Bootstrap Aggregating) — Breiman
- Generate
bootstrap samples from training data; train a base model (e.g., decision tree) on each; aggregate predictions: - classification: majority vote; regression: average.
- Reduces variance; models are independently trained.
- Out-of-bag (OOB) estimate: each model is tested on samples not in its bootstrap ⇒ free validation.
- Random Forest = bagging of deep, randomized decision trees (at each split choose best among a random subset of
features, typically ). Robust, accurate, handles high-D.
Boosting — turns weak into strong
- Sequentially train models; each new model focuses on examples the previous ones got wrong (re-weight misclassified examples).
- AdaBoost (Freund & Schapire):
initialize weights w_i = 1/n; for t = 1..T: train weak learner h_t using weights; compute error ε_t = Σ_{misclassified} w_i / Σ w_i; set α_t = 0.5·ln((1-ε_t)/ε_t); // weight of this learner update w_i ← w_i·exp(α_t·I(y_i≠h_t(x_i))); // up-weight mistakes renormalize w_i; final: H(x) = sign( Σ_t α_t h_t(x) );large when small (good learner trusted more). - Boosting reduces bias; sensitive to noisy/outlier labels.
- Gradient Boosting / GBM, XGBoost, LightGBM: fit new model to the residual (negative gradient) of current ensemble; powerful on tabular data.
| Method | Combines | Reduces | Train | Sensitivity |
|---|---|---|---|---|
| Bagging | parallel | variance | parallel | robust to noise |
| Boosting | sequential | bias | sequential | sensitive to noise |
| Random Forest | bagging + feature rand. | variance | parallel | robust |
4. Rule-Based Classification
Sequential Covering (Learn-One-Rule)
- Build a set of IF-THEN rules covering training examples:
Rules = ∅; while training examples remain uncovered: learn the "best" rule (greedy, using FOIL gain); add rule; remove covered examples; - FOIL gain for adding a literal:
, where = new positives covered, = precision before/after.
Rule Quality
- Coverage (support) and accuracy (confidence). Prune rules to avoid overfitting (e.g., reduced-error pruning).
- Direct methods (e.g., from decision trees: C4.5rules) convert a tree into rules then prune each rule independently — often more accurate and compact.
Advantages
- Highly interpretable ("IF age>30 AND income>50k THEN buy=yes").
- Can be more compact than a tree; easy to present to domain experts.
Other Advanced Classifiers (Brief)
- Logistic regression: linear model with sigmoid; outputs class probability; trained by MLE.
- Discriminant analysis (LDA/QDA): model class-conditional Gaussians.
- Nearest centroid / SVM ensembles / stacking: combiner learns how to blend base models.
SVM Margin (Geometric View)
The functional margin of example
which is equivalent to the soft-margin primal above. Only points achieving the margin (
Kernel Trick — Worked Intuition
XOR-like data not linearly separable in 2-D; map
AdaBoost — Worked Sketch
Start weights
- Round 1: weak rule
errs on 1 example ⇒ , . Up-weight the mistake; renormalize. - Round 2: next weak rule focuses on the up-weighted example; suppose
, . - Final
. Misclassified examples keep getting heavier weights until a later weak learner corrects them.
Comparison: When to Use Which
| Method | Interpretable? | Handles non-linear | Scales to big data | Needs labeled? |
|---|---|---|---|---|
| SVM | low | yes (kernel) | moderate | yes |
| Neural net | no | yes (deep) | yes (GPU) | yes (lots) |
| Bagging/RF | medium (RF) | yes | yes | yes |
| Boosting | low | yes | moderate | yes |
| Rule-based | high | limited | yes | yes |
Cost-Sensitive & Imbalanced Learning
- Fraud/disease are rare ⇒ accuracy misleads. Use class weights (higher penalty for minority errors), resampling (SMOTE/undersample), and evaluate by AUC / F1 / recall rather than accuracy.
- SVM/decision trees/boosting all accept instance or class weights.
SVM Dual Form (Compact)
The primal is solved via its dual (only dot products appear, enabling kernels):
subject to
Activation Functions (Neural Nets)
| Function | Range | Notes |
|---|---|---|
| Sigmoid | (0,1) | saturates, vanishing gradients |
| Tanh | (−1,1) | zero-centered, still saturates |
| ReLU | [0,∞) | fast, avoids saturation, needs care with dead units |
| Leaky/ELU | varies | mitigates dead ReLU |
Stacking (Meta Ensemble)
- Level-0 models (SVM, RF, NN) make predictions; a level-1 meta-learner (often logistic regression / linear model) learns how to combine them using cross-validated predictions as training input. Often the most accurate, but easy to overfit without careful CV.
Summary
Advanced classifiers extend beyond trees. SVM maximizes the margin and uses kernels to separate non-linearly via the dual/feature space, controlled by