Classification Algorithms

Explore a comprehensive guide to classification algorithms in AI with clear explanations, mathematical formulas, and illustrations on Programming Ocean Academy.

AI Algorithms Explainer

Logistic Regression (Classification)

$$ P(y=1|\mathbf{x}) = \frac{1}{1 + e^{-(\beta_0 + \mathbf{x}^\top \boldsymbol{\beta})}} $$

  • $P(y=1|\mathbf{x})$: Probability that input $\mathbf{x}$ belongs to class 1.
  • $\beta_0$: Intercept or bias term.
  • $\boldsymbol{\beta}$: Weight vector applied to features.
  • $e$: Base of natural logarithm used in the sigmoid function.
  • Decision Rule: Output is converted to class label based on threshold (commonly 0.5).
  • Use Case: Binary classification (e.g., spam detection, disease diagnosis).
  • Output: Probabilities, making it suitable for interpreting confidence.
Exam_pass_logistic_curve.jpeg

Linear Discriminant Analysis (LDA)

$$ y = \arg\max_k \left( \mathbf{x}^\top \Sigma^{-1} \boldsymbol{\mu}_k - \frac{1}{2} \boldsymbol{\mu}_k^\top \Sigma^{-1} \boldsymbol{\mu}_k + \log \pi_k \right) $$

  • $\mathbf{x}$: Input feature vector.
  • $\boldsymbol{\mu}_k$: Mean vector of class $k$.
  • $\Sigma$: Shared covariance matrix across all classes.
  • $\pi_k$: Prior probability of class $k$.
  • Goal: Find a linear combination of features that best separates multiple classes.
  • Assumption: Features are normally distributed with equal covariance across classes.
  • Use Case: Multi-class classification problems with linear decision boundaries.
LDA_Image.png

Quadratic Discriminant Analysis (QDA)

$$ y = \arg\max_k \left( -\frac{1}{2} \log |\Sigma_k| - \frac{1}{2} (\mathbf{x} - \boldsymbol{\mu}_k)^\top \Sigma_k^{-1} (\mathbf{x} - \boldsymbol{\mu}_k) + \log \pi_k \right) $$

  • $\mathbf{x}$: Input feature vector.
  • $\boldsymbol{\mu}_k$: Mean vector for class $k$.
  • $\Sigma_k$: Covariance matrix for class $k$ (distinct from other classes).
  • $\pi_k$: Prior probability of class $k$.
  • Quadratic Decision Boundary: Allows for more flexible class separation than LDA.
  • Assumption: Features are normally distributed, but each class can have its own covariance.
  • Use Case: Multi-class problems where class variances differ significantly.
page1-800px-QDA.pdf.jpg

Support Vector Classification (SVC)

$$ \hat{y} = \text{sign}(\mathbf{w}^\top \phi(\mathbf{x}) + b) $$

  • $\mathbf{x}$: Input feature vector.
  • $\phi(\mathbf{x})$: Mapping of input into a higher-dimensional space (via kernel).
  • $\mathbf{w}, b$: Weight vector and bias term.
  • Support Vectors: Data points closest to the decision boundary, defining the margin.
  • Kernel Trick: Allows non-linear classification without explicitly computing the mapping.
  • Common Kernels: Linear, Polynomial, RBF (Gaussian), Sigmoid.
  • Use Case: High-dimensional classification problems with clear margin separation.
SVM_margin.png

Linear Support Vector Machine (Linear SVM)

$$ \hat{y} = \text{sign}(\mathbf{w}^\top \mathbf{x} + b) $$
$$ \min_{\mathbf{w}, b} \frac{1}{2} \|\mathbf{w}\|^2 \quad \text{s.t. } y_i(\mathbf{w}^\top \mathbf{x}_i + b) \geq 1 $$

  • $\mathbf{x}$: Input feature vector.
  • $\mathbf{w}, b$: Weight vector and bias defining the decision boundary.
  • Hard Margin: Assumes linearly separable data, with no misclassification allowed.
  • Soft Margin (real-world use): Adds slack variables and penalty parameter $C$ to allow some misclassification.
  • Linear Kernel: No transformation; ideal for linearly separable problems.
  • Use Case: Fast and effective for high-dimensional sparse data (e.g., text classification).
Svm_separating_hyperplanes.png

Nu-Support Vector Classification (Nu-SVC)

$$ \hat{y} = \text{sign}(\mathbf{w}^\top \phi(\mathbf{x}) + b) $$
$$ \min \frac{1}{2} \|\mathbf{w}\|^2 + \frac{1}{\nu n} \sum \xi_i - \rho $$
subject to: $$ y_i(\mathbf{w}^\top \phi(\mathbf{x}_i) + b) \geq \rho - \xi_i, \quad \xi_i \geq 0, \quad \rho \geq 0 $$

  • $\nu$: Controls the upper bound on training errors and the lower bound on support vectors (between 0 and 1).
  • $\phi(\mathbf{x})$: Kernel-transformed feature space.
  • $\xi_i$: Slack variables for misclassification.
  • $\rho$: Margin parameter learned during training.
  • Flexibility: Nu-SVC is an alternative to C-SVC, offering more intuitive control over the model's complexity.
  • Use Case: Tasks requiring strict control over model generalization and sparsity.
SVM_margin.png

Decision Tree Classifier

$$ \text{Split Criterion:} \quad \text{Information Gain} = \text{Entropy(parent)} - \sum_{k} \frac{n_k}{n} \cdot \text{Entropy}(k) $$

  • Node: A decision point based on a feature threshold.
  • Leaf: Terminal node that outputs a class label.
  • Split Criterion: Commonly Information Gain (Entropy) or Gini Impurity.
  • Recursive Partitioning: Splits data based on the most informative feature.
  • Interpretability: Highly interpretable as a flowchart of decisions.
  • Pruning: Reduces overfitting by removing branches that add little predictive power.
  • Use Case: Classification tasks requiring transparency (e.g., medical diagnosis, compliance).
CART_tree_titanic_survivors.png

Random Forest Classifier

$$ \hat{y} = \text{majority\_vote}(\hat{y}^{(1)}, \hat{y}^{(2)}, \dots, \hat{y}^{(T)}) $$

  • $\hat{y}^{(t)}$: Prediction from the tth decision tree.
  • $T$: Total number of trees in the forest.
  • Bagging: Each tree is trained on a bootstrapped sample of the training data.
  • Feature Randomness: Each split considers a random subset of features.
  • Ensemble: Combines multiple weak learners to produce a strong classifier.
  • Robustness: Reduces variance and prevents overfitting better than a single tree.
  • Use Case: Versatile classifier effective for structured/tabular data (e.g., fraud detection, customer churn).
Random_forest_diagram_complete.png

Gradient Boosting Classifier

$$ F_m(x) = F_{m-1}(x) + \gamma_m h_m(x) $$
$$ \hat{y} = \text{sign}(F_M(x)) $$

  • $F_m(x)$: Ensemble model at iteration $m$.
  • $h_m(x)$: New weak learner fitted to the gradient of the loss function.
  • $\gamma_m$: Learning rate (step size).
  • Sequential Learning: Each tree corrects errors of its predecessor.
  • Loss Function: Typically log loss for classification; optimized using gradients.
  • High Accuracy: Performs well on both training and unseen data with tuning.
  • Use Case: Complex classification problems like click-through prediction, ranking, and customer segmentation.
Gradient_boosting_diagram.png

XGBoost Classifier

$$ \mathcal{L}^{(t)} = \sum_{i=1}^{n} l(y_i, \hat{y}_i^{(t-1)} + f_t(x_i)) + \Omega(f_t) $$

  • $l$: Log loss function for classification.
  • $f_t(x)$: Tree added at iteration $t$.
  • $\Omega(f_t)$: Regularization function controlling model complexity.
  • Efficiency: Includes optimizations like parallelization, cache awareness, and early stopping.
  • Robustness: Handles missing data, imbalanced classes, and overfitting well.
  • Regularized Boosting: Improves generalization by penalizing overly complex trees.
  • Use Case: Winning algorithm for many Kaggle competitions; ideal for structured data tasks like credit scoring, risk modeling, etc.
320px-XGBoost_logo.png

LightGBM Classifier

$$ \mathcal{L} = \sum_{i=1}^{n} l(y_i, \hat{y}_i) + \sum_{t=1}^{T} \Omega(f_t) $$

  • $l$: Binary log loss for classification tasks.
  • $f_t$: Prediction function (tree) at iteration $t$.
  • Histogram-based Learning: Efficient bucket-based feature binning for faster training.
  • Leaf-wise Tree Growth: Grows the leaf with maximum loss reduction first.
  • Advantages: Lower memory usage, faster computation, and higher accuracy for large datasets.
  • Handles: Large-scale classification problems and high-dimensional features effectively.
  • Use Case: Real-time ad click prediction, recommendation engines, and fraud detection.
LightGBM_logo.png

CatBoost Classifier

$$ \mathcal{L} = \sum_{i=1}^{n} l(y_i, \hat{y}_i) + \sum_{t=1}^{T} \Omega(f_t) $$

  • $l$: Log loss (binary/multi-class) used for classification tasks.
  • $f_t$: Decision tree model added at iteration t.
  • $\Omega(f_t)$: Regularization term penalizing complexity (tree depth, leaf count).
  • Ordered Boosting: Unique algorithm that handles categorical features more effectively by reducing prediction shift.
  • Automatic Encoding: Built-in support for categorical variables—no extensive preprocessing needed.
  • Robustness: Often performs well with minimal parameter tuning; handles class imbalance and missing values intelligently.
  • Use Case: Complex classification tasks involving structured/tabular data with categorical and numeric features (e.g., churn prediction, recommendation systems).
320px-CatBoost_logo.png

Extra Trees Classifier

$$ \hat{y} = \text{majority\_vote}(\hat{y}^{(1)}, \hat{y}^{(2)}, \dots, \hat{y}^{(T)}) $$

  • $\hat{y}^{(t)}$: Prediction from the tth randomized decision tree.
  • Extremely Randomized: Splits are selected at random, not based on optimal thresholds.
  • Ensemble Method: Builds a forest of unpruned trees using random samples and random splits.
  • Variance Reduction: Lower variance than a single decision tree, more randomness than a random forest.
  • Faster Training: Because it skips finding the best split during node construction.
  • Use Case: High-dimensional, noisy classification tasks where fast training and ensemble diversity matter.
Random_forest_diagram_complete.png

K-Nearest Neighbors (KNN) Classifier

$$ \hat{y} = \text{mode}(y_i), \quad \text{for } x_i \in \text{KNN}(x) $$

  • $x$: Query input vector to classify.
  • $x_i$: Nearest training samples to $x$.
  • $KNN(x)$: The $k$ closest data points to $x$ based on a distance metric (e.g., Euclidean).
  • Majority Voting: Class label is chosen based on the most common label among neighbors.
  • No Training: Lazy learner; classification occurs only during prediction.
  • Sensitive to Scale: Features should be normalized for meaningful distance computation.
  • Use Case: Small to medium-sized datasets with clearly clustered classes (e.g., image or document classification).
KnnClassification.png

Radius Neighbors Classifier

$$ \hat{y} = \text{mode}(y_i), \quad \text{for } x_i \in \{x_j : \|x - x_j\| \leq r\} $$

  • $x$: Input feature vector to classify.
  • $r$: Fixed radius around the query point.
  • $x_j$: All training samples within radius $r$ of $x$.
  • Majority Voting: Class is predicted based on the most common label of points within the radius.
  • Adaptability: More flexible than KNN in variable-density datasets.
  • No Prediction: If no points fall within the radius, prediction can default or be skipped.
  • Use Case: Ideal for unevenly distributed datasets where distance-based cutoff is more meaningful than a fixed number of neighbors.
KnnClassification.png

Multinomial Naive Bayes

$$ P(y|x_1, \dots, x_n) \propto P(y) \prod_{i=1}^{n} P(x_i|y)^{x_i} $$

  • $P(y)$: Prior probability of class $y$.
  • $P(x_i|y)$: Likelihood of observing feature $i$ (e.g., word) in class $y$.
  • $x_i$: Frequency count of feature $i$ in the input sample.
  • Multinomial Distribution: Suitable for count data like word occurrences in documents.
  • Laplace Smoothing: Helps handle features not observed in training for a class.
  • Use Case: Text classification (spam detection, news categorization) and document classification.
Naive_Bayes_diagram.svg

Bernoulli Naive Bayes

$$ P(y|x_1, \dots, x_n) \propto P(y) \prod_{i=1}^{n} P(x_i|y)^{x_i} (1 - P(x_i|y))^{1 - x_i} $$

  • $P(y)$: Prior probability of class $y$.
  • $x_i$: Binary feature (e.g., word presence = 1, absence = 0).
  • $P(x_i|y)$: Probability of feature $x_i$ being 1 given class $y$.
  • Binary Features: Model designed for 0/1 occurrence indicators rather than counts.
  • Comparison to Multinomial: Considers feature presence rather than frequency.
  • Use Case: Binary text features (e.g., keyword presence in spam detection, sentiment flags).
Naive_Bayes_diagram.svg

Complement Naive Bayes

$$ P(y|x) \propto \log P(y) + \sum_{i=1}^{n} x_i \log \left(\frac{P(x_i|\bar{y})}{P(x_i)}\right) $$

  • $P(x_i|\bar{y})$: Probability of feature $x_i$ in all classes except class $y$ (complement class).
  • Adjusts for Imbalance: Uses statistics from the complement of each class to reduce bias in imbalanced datasets.
  • $x_i$: Feature value (e.g., word count).
  • Log-Linear Model: Uses log probabilities for numerical stability and interpretability.
  • Use Case: Text classification problems with class imbalance (e.g., legal docs, healthcare records).
  • Improved Performance: More accurate than Multinomial NB on imbalanced datasets.
Naive_Bayes_diagram.svg

Multilayer Perceptron (MLP) Classifier

$$ \hat{y} = \text{softmax}(f_L(\dots f_2(f_1(\mathbf{x}W_1 + b_1)W_2 + b_2) \dots W_L + b_L)) $$

  • $\mathbf{x}$: Input feature vector.
  • $W_l, b_l$: Weights and biases of the lth layer.
  • $f_l$: Activation functions (e.g., ReLU, tanh).
  • Softmax Output: Used for multi-class classification.
  • Fully Connected Layers: Each layer is densely connected to the next.
  • Backpropagation: Algorithm used to update weights via gradient descent.
  • Use Case: Image recognition, text classification, tabular data with complex nonlinear patterns.
800px-Artificial_neural_network.svg.png

Deep Neural Network (DNN) Classifier

$$ \hat{y} = \text{softmax}(f^{(L)}(f^{(L-1)}(\dots f^{(2)}(f^{(1)}(\mathbf{x}W^{(1)} + b^{(1)})) \dots ))) $$

  • $\mathbf{x}$: Input feature vector.
  • $W^{(l)}, b^{(l)}$: Weights and biases of the lth layer.
  • $f^{(l)}$: Non-linear activation function at layer l (e.g., ReLU, ELU).
  • Softmax: Produces class probabilities for multi-class classification.
  • Depth: Multiple hidden layers for learning abstract and hierarchical features.
  • Training: Uses backpropagation and optimizers like Adam or SGD.
  • Use Case: Complex tasks such as image classification, speech recognition, and NLP problems.
800px-Colored_neural_network.svg.png

Convolutional Neural Network (CNN) Classifier

$$ y = \text{softmax}(f_{\text{fc}}(\text{flatten}(f_{\text{pool}}(f_{\text{conv}}(\mathbf{X}))))) $$

  • $\mathbf{X}$: Input image or grid data.
  • $f_{\text{conv}}$: Convolutional layers extracting local features.
  • $f_{\text{pool}}$: Pooling layers reducing spatial dimensions.
  • $\text{flatten}$: Converts feature maps into a 1D vector.
  • $f_{\text{fc}}$: Fully connected layers for final classification.
  • Softmax: Converts outputs into class probabilities.
  • Use Case: Image and video classification, medical image analysis, real-time object recognition.
Typical_cnn.png

Recurrent Neural Network (RNN) Classifier

$$ \begin{aligned} h_t &= f(W_{hh} h_{t-1} + W_{xh} x_t + b_h) \\ \hat{y} &= \text{softmax}(W_{hy} h_T + b_y) \end{aligned} $$

  • $x_t$: Input at time step $t$ (e.g., word or character).
  • $h_t$: Hidden state carrying information from previous time steps.
  • $W_{hh}, W_{xh}$: Weight matrices for recurrence and input.
  • $f$: Activation function (commonly tanh or ReLU).
  • $\hat{y}$: Final output after softmax, based on last hidden state $h_T$.
  • Sequential Data: Designed to handle temporal dependencies in sequences.
  • Use Case: Text classification, sentiment analysis, sequence labeling, time series classification.
800px-Recurrent_neural_network_unfold.svg.png

Long Short-Term Memory (LSTM) Classifier

$$ \begin{aligned} f_t &= \sigma(W_f \cdot [h_{t-1}, x_t] + b_f) \\ i_t &= \sigma(W_i \cdot [h_{t-1}, x_t] + b_i) \\ \tilde{C}_t &= \tanh(W_C \cdot [h_{t-1}, x_t] + b_C) \\ C_t &= f_t * C_{t-1} + i_t * \tilde{C}_t \\ o_t &= \sigma(W_o \cdot [h_{t-1}, x_t] + b_o) \\ h_t &= o_t * \tanh(C_t) \end{aligned} $$
$$ \hat{y} = \text{softmax}(W_{hy} h_T + b_y) $$

  • $x_t$: Input at time step $t$.
  • $h_t$: Hidden state capturing sequence context.
  • $C_t$: Memory cell preserving long-term dependencies.
  • Gates: Forget ($f_t$), input ($i_t$), and output ($o_t$) gates manage information flow.
  • $\hat{y}$: Output prediction after softmax layer.
  • Strength: Overcomes vanishing gradient issues in traditional RNNs.
  • Use Case: Text classification, language modeling, document categorization, video analysis.
The_LSTM_cell.png

Gated Recurrent Unit (GRU) Classifier

$$ \begin{aligned} z_t &= \sigma(W_z \cdot [h_{t-1}, x_t]) \\ r_t &= \sigma(W_r \cdot [h_{t-1}, x_t]) \\ \tilde{h}_t &= \tanh(W_h \cdot [r_t * h_{t-1}, x_t]) \\ h_t &= (1 - z_t) * h_{t-1} + z_t * \tilde{h}_t \\ \hat{y} &= \text{softmax}(W_{hy} h_T + b_y) \end{aligned} $$

  • $x_t$: Input at time step $t$.
  • $h_t$: Hidden state at time $t$, containing information from the sequence.
  • $z_t$: Update gate controlling how much past information to keep.
  • $r_t$: Reset gate controlling how much past state to forget.
  • $\tilde{h}_t$: Candidate hidden state.
  • $\hat{y}$: Output class probabilities after softmax.
  • Efficiency: Simpler than LSTM while retaining performance for many tasks.
  • Use Case: NLP tasks, audio classification, sequential labeling with fewer training parameters than LSTM.
Gated_Recurrent_Unit.svg

Transformer-based Classifiers (e.g., BERT, RoBERTa)

$$ \text{Output} = \text{softmax}(W[\text{CLS}] + b), \quad \text{CLS} = \text{Transformer}(\text{Input}) $$

  • Transformer: Uses self-attention to capture dependencies between all input tokens.
  • [CLS] Token: Special token representing the entire input sequence for classification.
  • Output: Class probabilities via a softmax over the final [CLS] representation.
  • Pretraining: Models are pre-trained on large corpora (e.g., masked language modeling).
  • Fine-tuning: Adapts the model to specific tasks like sentiment analysis or topic classification.
  • Use Case: State-of-the-art performance in NLP tasks including document classification, intent detection, and toxic comment filtering.
800px-BERT_Model_Overview.png

Bagging Classifier

$$ \hat{y} = \text{majority\_vote}(\hat{y}^{(1)}, \hat{y}^{(2)}, \dots, \hat{y}^{(T)}) $$

  • Base Estimators: Multiple classifiers (e.g., decision trees) trained independently.
  • Bootstrap Sampling: Each base model is trained on a different bootstrapped subset of the data.
  • Voting: Predictions from all base models are aggregated by majority voting (classification).
  • Variance Reduction: Helps reduce overfitting of high-variance models.
  • Parallel Training: Each model can be trained in parallel, improving scalability.
  • Use Case: Improves stability and accuracy in noisy or complex classification tasks (e.g., spam detection, credit scoring).
Ensemble_Bagging.svg

Voting Classifier

$$ \hat{y} = \text{argmax}_k \sum_{j=1}^{M} \mathbb{I}(\hat{y}_j = k) $$
(for hard voting) or
$$ \hat{y} = \text{argmax}_k \sum_{j=1}^{M} w_j \cdot P_j(y = k | x) $$
(for soft voting)

  • $\hat{y}_j$: Prediction from classifier $j$.
  • $M$: Number of classifiers in the ensemble.
  • $w_j$: Weight assigned to classifier $j$ (used in soft voting).
  • Hard Voting: Chooses the class with the majority of votes.
  • Soft Voting: Averages predicted class probabilities and selects the highest.
  • Flexibility: Can combine models of different types (e.g., SVM + Tree + NB).
  • Use Case: Improves accuracy by aggregating multiple models; useful when models have complementary strengths.
Voting_ensemble.png

Stacking Classifier

$$ \begin{aligned} Z &= [\hat{y}^{(1)}, \hat{y}^{(2)}, \dots, \hat{y}^{(M)}] \\ \hat{y} &= \text{meta\_model}(Z) \end{aligned} $$

  • $\hat{y}^{(m)}$: Prediction from base classifier $m$.
  • $Z$: Combined output from base learners used as input to the meta-model.
  • Meta-Model: Learns to best combine base predictions (e.g., logistic regression).
  • Cross-Validation: Prevents overfitting by using CV to generate base outputs.
  • Heterogeneous Models: Combines different model types for increased predictive power.
  • Use Case: Competitions and production systems where maximizing accuracy is key (e.g., finance, healthcare).
Stacking_diagram.png

AdaBoost Classifier

$$ F(x) = \sum_{t=1}^{T} \alpha_t h_t(x), \quad \hat{y} = \text{sign}(F(x)) $$

  • $h_t(x)$: Weak learner (usually a shallow decision tree).
  • $\alpha_t$: Weight of learner $t$ based on accuracy (higher for better models).
  • Boosting: Sequential training where each new model focuses more on misclassified examples.
  • Weighting: Sample weights are updated after each iteration to emphasize harder cases.
  • Combination: Final prediction is a weighted vote of weak learners.
  • Use Case: Handles binary classification, especially in noisy datasets (e.g., text sentiment, churn detection).
AdaBoost2.png

Hidden Markov Model (HMM) Classifier

$$ P(O|\lambda) = \sum_{all~Q} P(O|Q, \lambda) P(Q|\lambda) $$
$$ \lambda = (\pi, A, B) $$

  • $O$: Observed sequence of features (e.g., acoustic signals, word tokens).
  • $Q$: Hidden state sequence explaining the observations.
  • $\pi$: Initial state distribution.
  • $A$: Transition probability matrix between hidden states.
  • $B$: Emission probabilities from states to observed symbols.
  • Classification: Assign class to a sequence by finding which model $\lambda$ gives the highest likelihood.
  • Use Case: Speech recognition, gesture recognition, gene sequence classification.
800px-HMMGraph.svg.png

Bayesian Network Classifier

$$ P(Y, X_1, \dots, X_n) = P(Y) \prod_{i=1}^{n} P(X_i | \text{Parents}(X_i)) $$

  • $Y$: Target class variable.
  • $X_i$: Input features.
  • $\text{Parents}(X_i)$: Set of parent nodes of $X_i$ in the directed acyclic graph.
  • Graph Structure: Encodes dependencies among variables with conditional probability tables (CPTs).
  • Inference: Uses Bayes' rule to compute $P(Y|X_1, \dots, X_n)$.
  • Expressiveness: Captures more complex dependencies than Naive Bayes.
  • Use Case: Diagnosis systems, risk assessment, bioinformatics, and probabilistic expert systems.
Bayes_net_example.png

Markov Logic Network (MLN) Classifier

$$ P(X = x) = \frac{1}{Z} \exp\left(\sum_{i} w_i n_i(x)\right) $$

  • $w_i$: Weight of the $i$-th first-order logic formula.
  • $n_i(x)$: Number of true groundings of the $i$-th formula in the world $x$.
  • $Z$: Normalization constant (partition function).
  • Hybrid Model: Combines logic (knowledge representation) with probabilistic graphical models.
  • Inference: Involves computing the most probable explanation or marginal probabilities over formulas.
  • Use Case: Natural language understanding, entity resolution, knowledge base completion, and semantic reasoning.
Markov_Logic_Network.png

Rule-Based Classifier

$$ \text{IF } \text{condition}_1 \land \dots \land \text{condition}_k \text{ THEN class } C $$

  • Rule: Logical expression mapping feature conditions to class labels.
  • IF-THEN Format: Simple structure increases interpretability.
  • Rule Set: May consist of one or more rules covering the data.
  • Decision Lists: Rules can be ordered with fallbacks (e.g., RIPPER, CN2).
  • Accuracy vs. Interpretability: Strikes balance in explainable AI.
  • Use Case: Fraud detection, medical diagnosis, compliance where human-readable rules are critical.
Decision_table_rules_example.svg

Decision Table Classifier

\[ \text{Lookup}(x) = \begin{cases} \text{Majority class in matching row} & \text{if match found} \\ \text{Default class} & \text{otherwise} \end{cases} \]

  • Structure: A table where each row corresponds to a rule (set of attribute conditions) and an associated class label.
  • Matching: The classifier looks for rows that match the input attributes.
  • Majority Voting: Among all matching rows, the most frequent class is predicted.
  • Default Rule: Used when no rule matches the input; typically the most frequent class in training data.
  • Simplicity: Easy to interpret and implement; good for small to medium categorical datasets.
  • Use Case: Medical expert systems, customer segmentation, small-scale decision automation.
Decision_table_rules_example.svg

One Rule (OneR) Classifier

$$ \text{OneR}(x) = \text{argmax}_c~ \text{freq}(c~|~x_a) $$

  • $x_a$: Value of a single feature (attribute) $a$.
  • $c$: Class label that occurs most frequently for $x_a$ in training data.
  • One Rule: Learns a single rule based on one feature that gives the best classification accuracy.
  • Simplicity: Extremely interpretable; creates rules like “if attribute = value then class = label.”
  • Benchmarking: Often used as a baseline to compare against more complex models.
  • Use Case: Education, rule discovery, and quick model prototyping on structured data.
OneR_classifier_example.png

K-Means with Label Propagation (Semi-Supervised)

$$ \mu_k = \frac{1}{|C_k|} \sum_{x_i \in C_k} x_i, \quad y_i = \text{mode}(\{y_j : x_j \in C_k \text{ and } y_j \text{ known}\}) $$

  • $\mu_k$: Centroid of cluster $k$.
  • $C_k$: Set of data points assigned to cluster $k$.
  • Label Propagation: Assigns cluster labels based on majority label among labeled instances in the cluster.
  • Semi-Supervised Learning: Combines a small set of labeled data with a larger set of unlabeled data.
  • K-Means Clustering: Groups data into $k$ clusters based on feature similarity.
  • Use Case: Scenarios where labeled data is scarce, such as text categorization, bioinformatics, and image classification.
K-means_convergence.gif

K-Means with Label Propagation (Semi-Supervised)

$$ \mu_k = \frac{1}{|C_k|} \sum_{x_i \in C_k} x_i, \quad y_i = \text{mode}(\{y_j : x_j \in C_k \text{ and } y_j \text{ known}\}) $$

  • $\mu_k$: Centroid of cluster $k$.
  • $C_k$: Set of data points assigned to cluster $k$.
  • Label Propagation: Assigns cluster labels based on majority label among labeled instances in the cluster.
  • Semi-Supervised Learning: Combines a small set of labeled data with a larger set of unlabeled data.
  • K-Means Clustering: Groups data into $k$ clusters based on feature similarity.
  • Use Case: Scenarios where labeled data is scarce, such as text categorization, bioinformatics, and image classification.
K-means_convergence.gif

Self-Organizing Maps (SOMs)

$$ \text{BMU} = \arg\min_j \| x - w_j \|, \quad w_j \leftarrow w_j + \alpha(t) \cdot h(j, \text{BMU}, t) \cdot (x - w_j) $$

  • $x$: Input vector to be mapped onto the grid.
  • $w_j$: Weight vector of node $j$ on the SOM grid.
  • BMU: Best Matching Unit, the node whose weight is closest to $x$.
  • $\alpha(t)$: Learning rate decreasing over time.
  • $h(j, \text{BMU}, t)$: Neighborhood function that determines the influence of BMU on node $j$.
  • Topology Preservation: Maps high-dimensional data onto a 2D space while preserving similarity.
  • Use Case: Unsupervised pretraining, visualization, and classification tasks in fields like genomics and speech recognition.
Self-organizing_map_neural_network.png

Learning Vector Quantization (LVQ)

$$ w_j \leftarrow w_j + \alpha(t)(x - w_j) \quad \text{if } \hat{y}_j = y \\ w_j \leftarrow w_j - \alpha(t)(x - w_j) \quad \text{if } \hat{y}_j \ne y $$

  • $x$: Input vector.
  • $w_j$: Prototype vector for class $j$.
  • $\alpha(t)$: Learning rate at time $t$.
  • $\hat{y}_j$: Predicted class based on closest prototype.
  • $y$: True class label of input.
  • Competitive Learning: Only the closest prototype is updated.
  • Use Case: Classification with interpretable prototypes, suitable for sensor data, signals, and industrial monitoring.
LVQ_prototype_movement.png

Ridge Classifier

$$ \hat{y} = \text{sign}(X\beta), \quad \text{where } \beta = \arg\min_\beta \left\| y - X\beta \right\|^2 + \alpha \|\beta\|^2 $$

  • $X$: Feature matrix.
  • $y$: Target class labels (binary, e.g., ±1).
  • $\beta$: Weight coefficients to be estimated.
  • $\alpha$: Regularization strength controlling the L2 penalty.
  • Linear Classifier: Uses ridge regression and applies sign thresholding for classification.
  • Stability: Reduces model variance in high-dimensional data.
  • Use Case: Text categorization, signal classification, and high-dimensional binary classification tasks.
Ridge_regression_illustration.png

Passive Aggressive Classifier

$$ \beta_{t+1} = \beta_t + \tau_t y_t x_t, \quad \text{where } \tau_t = \frac{\max(0, 1 - y_t \langle \beta_t, x_t \rangle)}{\|x_t\|^2} $$

  • $x_t$: Input vector at time $t$.
  • $y_t$: True label ($\pm1$).
  • $\beta_t$: Model weight vector at time $t$.
  • $\tau_t$: Step size based on the hinge loss.
  • Passive: No update if prediction is correct with a sufficient margin.
  • Aggressive: Updates are made when predictions are incorrect or too close to the margin.
  • Use Case: Online learning scenarios such as news categorization, real-time spam filtering, and stock movement prediction.
Passive-aggressive-classifier.png

Quadratic Kernel Classifier

$$ K(x_i, x_j) = (x_i^\top x_j + c)^2, \quad \hat{y} = \text{sign} \left( \sum_i \alpha_i y_i K(x_i, x) + b \right) $$

  • $K(x_i, x_j)$: Quadratic kernel function measuring similarity between samples.
  • $c$: A constant that trades off high-order and low-order terms.
  • $\alpha_i$: Model coefficients determined during training (as in SVM).
  • Non-linear Separation: Transforms data into a higher-dimensional space where a quadratic decision boundary is linear.
  • Use Case: Suitable for tasks where the relationship between classes is non-linear but still smooth, such as bioinformatics, handwriting recognition, and image classification.
SVM_margin.png

One-vs-Rest (OvR) Classification

$$ \hat{y} = \arg\max_k f_k(x), \quad \text{where } f_k(x) = \text{score for class } k $$

  • Strategy: Train one binary classifier per class vs. all other classes.
  • Prediction: The classifier with the highest confidence score determines the predicted class.
  • Scalability: Efficient for multi-class problems using binary classifiers (e.g., SVM, logistic regression).
  • Independence: Each classifier is trained independently, allowing parallel computation.
  • Use Case: General-purpose classification for multi-class datasets (e.g., text, medical diagnosis).
One-vs-rest.png

One-vs-One (OvO) Classification

$$ \hat{y} = \text{majority\_vote}(\{f_{ij}(x) : i < j\}), \quad \text{where } f_{ij} \text{ is classifier between class } i \text{ and } j $$

  • Strategy: Build a binary classifier for every pair of classes.
  • Number of Models: For $K$ classes, $\frac{K(K - 1)}{2}$ classifiers are trained.
  • Voting: Each classifier casts a vote; the class with the most votes is predicted.
  • Fine-Grained Distinction: Useful when class boundaries are tight and class pairs require focused separation.
  • Use Case: Suitable for algorithms like SVM in datasets with moderate class counts (e.g., digit recognition, image labeling).
One_vs_One_classification.svg

Classifier Chains

$$ \hat{y}_1 = f_1(x), \quad \hat{y}_2 = f_2(x, \hat{y}_1), \quad \dots, \quad \hat{y}_L = f_L(x, \hat{y}_1, \dots, \hat{y}_{L-1}) $$

  • $f_i$: Binary classifier for label $i$, incorporating predictions of previous labels.
  • $\hat{y}_i$: Predicted value for label $i$.
  • Label Dependency: Accounts for interdependencies between labels in multi-label tasks.
  • Chained Prediction: Each prediction influences the subsequent classifiers.
  • Sequential Nature: Sensitive to label ordering; ensemble of chains can improve stability.
  • Use Case: Document categorization, medical diagnosis, or any scenario with overlapping labels.
Classifier_chain_diagram.svg

Binary Relevance

$$ \hat{y}_i = f_i(x), \quad \text{for } i = 1, 2, \dots, L $$

  • $f_i$: Independent binary classifier trained for label $i$.
  • $\hat{y}_i$: Predicted presence (1) or absence (0) of label $i$ for input $x$.
  • Independence Assumption: Assumes no dependency between labels.
  • Scalability: Easy to implement and scale to large label spaces.
  • Limitations: Ignores correlations between labels.
  • Use Case: Multi-label text classification, music tagging, gene function prediction.
Binary_relevance_diagram.svg

Label Powerset

$$ \hat{y} = f(x), \quad f : \mathcal{X} \rightarrow \mathcal{P}(L) $$

  • $f(x)$: Multi-class classifier trained to predict entire label combinations as single classes.
  • $\mathcal{P}(L)$: Power set of all label combinations observed in the training data.
  • Transformation: Converts multi-label classification into a multi-class problem.
  • Label Correlation: Naturally captures label dependencies.
  • Scalability Issue: May not scale well with large label sets due to exponential growth in combinations.
  • Use Case: Useful in tasks with strong label co-occurrence patterns (e.g., music genre classification, legal document tagging).
Label_powerset_multi-label_classification.svg