Skip to content
New
Latest News || 7 October 2026: Quiz and Pizza Night — Titanic Crew placed fourth. || 3 October 2026: Serving as a Student Ambassador at Queen's University Belfast, welcoming prospective students and visitors and supporting EEECS tours and event activities. || 9 September 2026: Published at AP-S/URSI 2026: “Near Field-Aware UE Localization in RIS-Aided Wireless Networks Through ML-Regressor.” || 25 August 2026: Poster presentation at UCMMT 2026 in Birmingham — “Experimental Validation of Localisation in RIS-Assisted mmWave Networks.” || 18 August 2026: Published at EuCAP 2026: “Impact of RIS Size on Machine Learning-Enabled Beam Sweeping for User Localization.”
Knowledge Hubmachine learningClassification Algorithms

machine learning learning note

Classification Algorithms

A deeper guide to common classification algorithms, their intuition, strengths, weaknesses, and practical use cases.

What is a Classification Algorithm?

A classification algorithm learns how to assign an input to a class. The input can be a row of tabular data, an image, a sentence, a signal sample, or a set of measured features. The output is a label such as "spam", "normal", "fault", "LOS", or "NLOS".

Different classifiers make different assumptions. Some draw simple linear boundaries. Some split data into tree-like rules. Some compare a new point with stored examples. Some combine many weak models into a stronger model.

References for this section3

1. Logistic Regression

Logistic regression is one of the best starting points for binary classification. Despite the word "regression", it is used to estimate the probability of a class.

Logistic regression picture
linear score -> sigmoid -> probability -> class label

Concept adapted from Tpoint Tech/Javatpoint logistic-regression explanations and scikit-learn LogisticRegression documentation.

References for this section3

Intuition

The model computes a weighted sum of the features, then passes it through a sigmoid function. The result is a probability.

Logistic Regression Score
z = β₀ + β₁x₁ + β₂x₂ + ⋯ + βₚxₚ
Sigmoid Probability
P(y = 1 | x) = σ(z) = 1 / (1 + e⁻ᶻ)

If the probability is above a chosen threshold, the model predicts class 1; otherwise, class 0.

References for this section3

Strengths

  • Fast to train.
  • Easy to interpret.
  • Strong baseline for many problems.
  • Works well when the decision boundary is roughly linear.
References for this section3

Weaknesses

  • Struggles with complex non-linear patterns unless features are engineered.
  • Sensitive to irrelevant features and poor scaling.
  • May underfit when the true relationship is highly complex.
References for this section3

Best Use Cases

  • Medical risk scoring.
  • Spam detection baselines.
  • Credit scoring.
  • Any problem where interpretability is important.
References for this section3

2. K-Nearest Neighbors

K-nearest neighbors (KNN) is a memory-based classifier. It does not learn a compact equation during training. Instead, it stores the training examples and compares new examples to them.

KNN picture
Find nearby points
Count neighbor labels
Predict majority class
References for this section3

Intuition

To classify a new point:

  1. Measure its distance to all training points.
  2. Find the K closest points.
  3. Take a majority vote among their labels.

If K = 5 and three neighbors are class A while two are class B, the model predicts class A.

References for this section3

Strengths

  • Very simple.
  • No explicit training phase.
  • Can learn non-linear boundaries.
  • Useful for small and well-scaled datasets.
References for this section3

Weaknesses

  • Slow prediction for large datasets.
  • Sensitive to feature scaling.
  • Performs poorly with many irrelevant features.
  • Suffers in high-dimensional spaces.
References for this section3

Best Use Cases

  • Small datasets.
  • Recommendation prototypes.
  • Simple pattern recognition where distance is meaningful.
References for this section3

3. Decision Trees

A decision tree classifies by asking a sequence of questions. Each internal node tests a feature, each branch is an answer, and each leaf gives a final class.

References for this section3

Intuition

For example, a tree for link quality might ask:

Is SNR > 15 dB?
  yes -> Is delay spread low?
  no  -> Bad link

The tree learns which questions split the data most effectively. Common splitting criteria include Gini impurity and information gain.

References for this section3

Strengths

  • Easy to explain.
  • Handles numerical and categorical data.
  • Captures non-linear rules.
  • Requires little preprocessing.
References for this section3

Weaknesses

  • Can overfit badly if allowed to grow too deep.
  • Small changes in data can change the tree.
  • Single trees are usually less accurate than ensembles.
References for this section3

Best Use Cases

  • Explainable rule-based decisions.
  • Quick exploratory modeling.
  • Problems where human-readable logic matters.
References for this section3

4. Support Vector Machines

Support Vector Machines (SVMs) try to find a boundary that separates classes with the largest possible margin.

SVM picture
class A | margin | decision boundary | margin | class B

Concept adapted from margin-based SVM diagrams in Tpoint Tech/Javatpoint and support-vector-network literature.

References for this section3

Intuition

The best boundary is not only one that separates the classes; it is the one that leaves the widest gap between them. The closest training points to the boundary are called support vectors.

For non-linear problems, SVMs use kernels. A kernel lets the algorithm behave as if the data were mapped into a higher-dimensional space, without explicitly computing all those new dimensions.

References for this section3

Strengths

  • Works well in high-dimensional data.
  • Effective when the number of features is large.
  • Kernel trick handles non-linear boundaries.
  • Strong theoretical foundation.
References for this section3

Weaknesses

  • Slow for very large datasets.
  • Hyperparameter tuning is important.
  • Results are less interpretable than logistic regression or trees.
References for this section3

Best Use Cases

  • Text classification.
  • Bioinformatics.
  • Medium-sized datasets with many features.
  • Problems where a strong margin-based classifier is useful.
References for this section3

5. Random Forest

Random forest is an ensemble of decision trees. Instead of trusting one tree, it trains many trees and combines their predictions.

References for this section3

Intuition

Each tree sees a random sample of the data and a random subset of features. Because the trees are different, their errors are partly different. Voting across many trees reduces the instability of a single tree.

References for this section3

Strengths

  • Strong performance on tabular data.
  • Reduces decision-tree overfitting.
  • Handles non-linear feature interactions.
  • Provides feature importance estimates.
  • Works with little preprocessing.
References for this section3

Weaknesses

  • Less interpretable than a single tree.
  • Larger memory usage.
  • Cannot extrapolate beyond patterns seen in training.
References for this section3

Best Use Cases

  • General tabular classification.
  • Baselines for structured data.
  • Problems with mixed feature types.
References for this section3

6. Gradient Boosting and XGBoost

Gradient boosting also uses many trees, but it builds them sequentially. Each new tree tries to correct the errors made by the previous trees.

References for this section3

Intuition

Random forest builds many independent trees and averages them. Boosting builds a team in order: tree 1 makes mistakes, tree 2 focuses on those mistakes, tree 3 corrects remaining errors, and so on.

XGBoost is a highly optimized implementation of gradient-boosted trees. It became popular because it is accurate, regularized, scalable, and very effective on structured data.

References for this section3

Strengths

  • Excellent accuracy on tabular data.
  • Handles non-linear interactions.
  • Includes regularization to control overfitting.
  • Often performs better than random forest when tuned carefully.
References for this section3

Weaknesses

  • More hyperparameters to tune.
  • Can overfit if trees are too deep or learning rate is too high.
  • Less transparent than simple models.
References for this section3

Best Use Cases

  • Structured/tabular datasets.
  • Competitions and high-performance prediction tasks.
  • Risk scoring, churn prediction, demand forecasting, and ranking tasks.
References for this section3

7. Neural Network Classifiers

Neural networks are useful when the input is complex, high-dimensional, or weakly structured, such as images, audio, text, or raw sensor streams.

References for this section3

Intuition

A neural network learns layers of representation. Early layers learn simple patterns, while deeper layers combine them into more abstract concepts.

References for this section3

Strengths

  • Powerful for images, language, speech, and large datasets.
  • Learns features automatically.
  • Can model highly complex boundaries.
References for this section3

Weaknesses

  • Requires more data and compute.
  • Harder to interpret.
  • More sensitive to architecture and training choices.
References for this section3

Model Selection Guide

NeedGood starting model
Simple, interpretable baselineLogistic regression
Small dataset with meaningful distanceKNN
Human-readable rulesDecision tree
Strong classifier for many featuresSVM
Reliable tabular baselineRandom forest
High-performance tabular predictionXGBoost or gradient boosting
Images, speech, text, raw signalsNeural network
References for this section3

Evaluation Checklist

  • Use a separate test set.
  • Check class imbalance.
  • Report precision, recall, F1-score, and confusion matrix.
  • Tune thresholds when false positives and false negatives have different costs.
  • Use cross-validation when data is limited.
  • Inspect failure cases, not only summary metrics.
References for this section3

Python: Load Common Classifiers

All of these scikit-learn classifiers use the same core methods:

  • fit(X_train, y_train) learns from data.
  • predict(X_test) returns class labels.
  • predict_proba(X_test) returns probabilities when supported.
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import KNeighborsClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.naive_bayes import GaussianNB

classifiers = {
    "logistic_regression": LogisticRegression(max_iter=1000),
    "knn": KNeighborsClassifier(n_neighbors=5),
    "decision_tree": DecisionTreeClassifier(max_depth=5, random_state=42),
    "svm": SVC(kernel="rbf", probability=True),
    "random_forest": RandomForestClassifier(n_estimators=200, random_state=42),
    "gradient_boosting": GradientBoostingClassifier(random_state=42),
    "naive_bayes": GaussianNB(),
}
References for this section3

Python: Compare Classifiers on One Dataset

from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import accuracy_score, f1_score

X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42, stratify=y
)

for name, clf in classifiers.items():
    # Scaling helps distance/kernel/linear methods; tree models do not need it,
    # but keeping one pipeline makes comparison simple.
    model = make_pipeline(StandardScaler(), clf)
    model.fit(X_train, y_train)
    pred = model.predict(X_test)

    print(
        name,
        "accuracy=", round(accuracy_score(y_test, pred), 3),
        "f1=", round(f1_score(y_test, pred), 3),
    )
References for this section3

Python: Save and Load a Trained Classifier

import joblib

best_model = make_pipeline(
    StandardScaler(),
    RandomForestClassifier(n_estimators=300, random_state=42)
)
best_model.fit(X_train, y_train)

joblib.dump(best_model, "classifier.joblib")

loaded_model = joblib.load("classifier.joblib")
print(loaded_model.predict(X_test[:5]))
References for this section3

Takeaway

No classifier is best for every problem. Start with a simple baseline, understand the data, choose metrics that match the real cost of mistakes, and increase model complexity only when the simpler model is not enough.

References for this section3

Complete references and further reading