Skip to content
New
Latest News || 27 October 2026: Dr Soumava Mukherjee's invited talk at Queen's University Belfast joined device-level hardware innovation with channel-level control. || 22 October 2026: I received a Certificate of Appreciation for serving as a reviewer for IEEE IMAS 2026. || 15 October 2026: I presented a poster on beam-domain ML fingerprinting for RIS-aided mmWave localisation at the Centre for Wireless Innovation's annual symposium. || 15 October 2026: CWI's annual symposium brought research and industry perspectives on 6G, ISAC, optical wireless, AI, and future networks to Queen's University Belfast. || 14 October 2026: Erik Nordell of Ericsson visited our Keysight Lab for a live RIS-assisted video streaming demonstration.
Knowledge Hubmachine learning5. Classification Algorithms

machine learning learning note

5. Classification Algorithms

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

At a glance

  • Match the model to the structureLogistic regression is a linear baseline; KNN uses distance; trees use splits; ensembles combine models.
  • See which neighbours voteUniform KNN predicts the majority label among the k closest training points. Feature scaling changes who is close.
  • Choose with held-out evidenceUse the same validation scheme and error-cost metrics across models, then evaluate the selected system once on the final test set.

What is a Classification Algorithm?

Classification assigns one of several labels to an input.

  • Input: tabular row, image, text, signal sample, or measured feature vector.
  • Output: a class such as "LOS" or "NLOS", not a distance or power value.
  • Evaluation: compare predictions with labels on held-out examples.

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.

How does logistic regression learn a straight boundary?

1. Formula and symbols
z=w1x1+w2x2+b,p=σ(z)=11+e−zz=w_1x_1+w_2x_2+b,\qquad p=\sigma(z)=\frac{1}{1+e^{-z}}
L=−1n∑i=1n[yiln⁡pi+(1−yi)ln⁡(1−pi)]L=-\frac1n\sum_{i=1}^{n}\big[y_i\ln p_i+(1-y_i)\ln(1-p_i)\big]
wj←wj−η 1n∑i(pi−yi)xij,b←b−η 1n∑i(pi−yi)w_j\leftarrow w_j-\eta\,\frac1n\sum_i(p_i-y_i)x_{ij},\qquad b\leftarrow b-\eta\,\frac1n\sum_i(p_i-y_i)
  • x1x_1: SNR, rescaled so 0 dB → −1 and 30 dB → +1
  • x2x_2: Delay spread, rescaled so 0 ns → −1 and 300 ns → +1
  • w1, w2w_1,\ w_2: Learned feature weights
  • bb: Learned bias (intercept)
  • zz: Linear score before the sigmoid
  • pp: Predicted probability that the link is good
  • yiy_i: True label of example i (1 = good link, 0 = bad link)
  • LL: Average cross-entropy (log) loss
  • η\eta: Learning rate
  • τ\tau: Decision threshold: predict good when p ≥ τ

The boundary p = τ is the straight line z = ln(τ/(1−τ)); logistic regression can only draw straight boundaries in the original features.

015300150300SNR (dB)Delay spread (ns)−80800.51score zp = σ(z)τ = 0.5△ good link · ○ bad link · orange line: p = τ
2. Work with the current inputs
w1=4.99,w2=−2.81,b=0.05after 60 updatesw_1=4.99,\quad w_2=-2.81,\quad b=0.05\quad\text{after }60\text{ updates}
∂L∂w=[−0.0161, 0.0031],∂L∂b=0.0005\frac{\partial L}{\partial w}=\big[-0.0161,\ 0.0031\big],\quad\frac{\partial L}{\partial b}=0.0005
boundary: 4.99x1−2.81x2+0.05=ln⁡0.50.50=0.00\text{boundary: }4.99x_1-2.81x_2+0.05=\ln\tfrac{0.5}{0.50}=0.00
3. Result
Log loss L0.200starts at ln 2 = 0.693
Training accuracy92.5%
Weights w₁ / w₂4.99 / -2.81SNR helps (+), delay hurts (−)
Forty illustrative links with two features, SNR and delay spread; good links (triangles) cluster at high SNR and low delay. Weights start at zero and move by full-batch gradient descent on the log loss. Left: probability shading and the p = τ boundary. Right: every link placed on the sigmoid curve by its score z. The two clouds overlap, so no straight line can classify every link correctly.
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.

z=β0+∑j=1pβjxjz=\beta_0+\sum_{j=1}^{p}\beta_jx_j
  • zz: score before conversion to a probability.
  • xjx_{j}: input feature j.
  • βj\beta _{j}: learned weight for feature j.
  • β0\beta _{0}: bias or intercept.
  • pp: number of input features.
P(y=1∣x)=σ(z)=11+e−zP(y=1\mid x)=\sigma(z)=\frac1{1+e^{-z}}
  • P(y=1∣x)P(y=1\mid x): probability of class 1 for input x.
  • σ\sigma: sigmoid function.
  • zz: weighted model score before the sigmoid.
  • ee: base of the natural exponential.

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.

Which neighbours actually determine this class?

1. Formula and symbols
di2=(xi−x)2+(yi−y)2d_i^2=(x_i-x)^2+(y_i-y)^2
c^=1 ⁣[∑i∈Nkci>k/2]\widehat c=\mathbf1\!\left[\sum_{i\in\mathcal N_k}c_i>k/2\right]
  • xx: First query feature
  • yy: Second query feature
  • xix_i: First feature of training sample i
  • yiy_i: Second feature of training sample i
  • did_i: Euclidean distance
  • cic_i: binary training class
  • Nk\mathcal N_k: k nearest samples
  • c^\widehat c: uniform-majority prediction

Odd k avoids voting ties here.

○ Class 0 · △ Class 1 · Ring: query · Lines: selected neighboursx: −1 → +1; y: −1 (bottom) → +1 (top)
2. Work with the current inputs
di2=(xi−0.20)2+(yi−0.20)2d_i^2=(x_i-0.20)^2+(y_i-0.20)^2
y^=1 ⁣[∑i∈N3yi>3/2]=0\widehat y=\mathbf1\!\left[\sum_{i\in\mathcal N_3}y_i>3/2\right]=0
3. Result
Predicted class0
Class-1 neighbour votes1 / 3
Closest squared distance0.044
Forty fixed synthetic labelled points in normalized two-feature coordinates; the generating labels follow an XOR-like quadrant rule. Uniform-vote KNN uses Euclidean distance, no fitted scaler and no test-performance claim. Background is the calculated decision region for the selected k. Changing the query does not retrain or add it to the dataset.
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.

How does a decision tree carve the feature space?

1. Formula and symbols
G(S)=1−p12−p02G(S)=1-p_1^2-p_0^2
Gsplit=nLnG(SL)+nRnG(SR),ΔG=G(S)−GsplitG_{\rm split}=\frac{n_L}{n}G(S_L)+\frac{n_R}{n}G(S_R),\qquad\Delta G=G(S)-G_{\rm split}
  • SS: Set of training links that reach a node
  • p1p_1: Fraction of good links in S
  • p0p_0: Fraction of bad links in S (p₀ = 1 − p₁)
  • GG: Gini impurity: 0 for a pure node, 0.5 for a 50/50 node
  • SL, SRS_L,\ S_R: Links sent left (feature ≤ threshold) and right
  • n, nL, nRn,\ n_L,\ n_R: Number of links in S, S_L and S_R
  • ΔG\Delta G: Impurity decrease; the tree picks the split with the largest ΔG

CART tries every feature and every midpoint between sorted values, keeps the best split, then repeats inside each child until the depth limit or a pure node.

015300150300SNR (dB)Delay spread (ns)The tree as questionsSNR ≤ 16.7 dB? · 22/60 goodyes → SNR ≤ 1.5 dB? · 3/37 goodyes → GOOD · 2/2 goodno → delay ≤ 20 ns? · 1/35 goodyes → BAD · 1/4 goodno → BAD · 0/31 goodno → SNR ≤ 22.2 dB? · 19/23 goodyes → delay ≤ 174 ns? · 6/10 goodyes → GOOD · 6/6 goodno → BAD · 0/4 goodno → GOOD · 13/13 good△ good · ○ bad · orange lines: learned splits
2. Work with the current inputs
G(root)=1−(2260)2−(3860)2=0.464G(\text{root})=1-\left(\tfrac{22}{60}\right)^2-\left(\tfrac{38}{60}\right)^2=0.464
best root split: SNR≤16.7 dB⇒nL=37, nR=23\text{best root split: SNR}\le16.7\text{ dB}\Rightarrow n_L=37,\ n_R=23
Gsplit=3760(0.149)+2360(0.287)=0.202,ΔG=0.262G_{\rm split}=\tfrac{37}{60}(0.149)+\tfrac{23}{60}(0.287)=0.202,\quad\Delta G=0.262
3. Result
Leaves (regions)6
Training accuracy98.3%
Agreement with hidden rule88.5%on a 40 × 40 grid
Sixty illustrative links labelled by a hidden rule (good if SNR > 15 dB and delay < 150 ns, or SNR > 24 dB) with four labels flipped as noise. Each extra level lets every region ask one more yes/no question, so the boundary stays made of horizontal and vertical steps. Deeper trees fit the noisy points too; the rule-agreement score checks a 40 × 40 grid against the noise-free rule.
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.

What does the SVM margin look like, and what does C change?

1. Formula and symbols
min⁡w,b,ξ 12∥w∥2+C∑i=1nξis.t.yi(w⊤xi+b)≥1−ξi,  ξi≥0\min_{w,b,\xi}\ \tfrac12\lVert w\rVert^2+C\sum_{i=1}^{n}\xi_i\quad\text{s.t.}\quad y_i(w^\top x_i+b)\ge1-\xi_i,\ \ \xi_i\ge0
margin width=2∥w∥,w=∑iαiyixi,0≤αi≤C\text{margin width}=\frac{2}{\lVert w\rVert},\qquad w=\sum_i\alpha_iy_ix_i,\quad0\le\alpha_i\le C
  • xix_i: Feature vector of link i (SNR, delay spread), rescaled to [−1, 1]
  • yiy_i: Label written as +1 (good) or −1 (bad)
  • ww: Normal vector of the boundary
  • bb: Offset of the boundary
  • ξi\xi_i: Slack: how far link i is inside the margin or on the wrong side
  • CC: Penalty on slack; large C tolerates fewer margin violations
  • αi\alpha_i: Dual weight of link i; links with α > 0 are the support vectors

Solved by dual coordinate descent. The bias is learned as a weight on a constant feature, so it is lightly regularised too.

015300150300SNR (dB)Delay spread (ns)Reading the pictureSolid line: decision boundaryDashed lines: margin edges (±1)Ring: support vector (α > 0)Links outside the dashed band haveα = 0 and could move withoutchanging the boundary.Now: 16 support vectors,margin 0.78 wide.△ good · ○ bad · ring: support vector
2. Work with the current inputs
w=(2.36, −1.04),b=0.21,∥w∥=2.576w=(2.36,\ -1.04),\quad b=0.21,\quad\lVert w\rVert=2.576
margin=22.576=0.776 (normalised feature units)\text{margin}=\frac{2}{2.576}=0.776\ \text{(normalised feature units)}
#{αi>0}=16,#{yif(xi)<1}=14,C=1.0\#\{\alpha_i>0\}=16,\quad\#\{y_if(x_i)<1\}=14,\quad C=1.0
3. Result
Margin width 2/‖w‖0.776
Support vectors16 of 40
Inside margin / misclassified14 / 3
The same forty links as the logistic-regression lab. Solid orange: the boundary w·x + b = 0. Dashed: the margin edges w·x + b = ±1. Ringed links are support vectors; only they decide where the boundary goes. Small C buys a wide margin by letting many links sit inside it; large C narrows the margin to push links out.
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.

Why does a vote of many trees beat one tree?

1. Formula and symbols
Dt∼bootstrap(D),ht=tree trained on Dt\mathcal D_t\sim\text{bootstrap}(\mathcal D),\qquad h_t=\text{tree trained on }\mathcal D_t
v(x)=1T∑t=1Tht(x),y^(x)=1[v(x)≥0.5]v(x)=\frac1T\sum_{t=1}^{T}h_t(x),\qquad\widehat y(x)=\mathbf 1[v(x)\ge0.5]
  • D\mathcal D: Original training set of 60 links
  • Dt\mathcal D_t: Bootstrap sample: 60 draws from D with replacement
  • ht(x)h_t(x): Class (0 or 1) predicted by tree t
  • TT: Number of trees
  • v(x)v(x): Vote share for the good class
  • y^(x)\widehat y(x): Majority-vote prediction

Each split here may only look at one randomly chosen feature (max_features = 1), which makes the trees disagree; averaging their votes smooths the single tree's jagged regions.

015300150300SNR (dB)Delay spread (ns)P3 of the 9 trees (own samples)tree 1tree 2tree 3Large panel = average of all votesdeep teal: most trees say gooddeep purple: most trees say badpale: the trees disagree△ good · ○ bad · P: probe link
2. Work with the current inputs
v(P)=19∑tht(P)=59=0.56⇒y^(P)=1v(P)=\frac{1}{9}\sum_t h_t(P)=\frac{5}{9}=0.56\Rightarrow\widehat y(P)=1
P=(SNR=18.8 dB, delay=165 ns)P=(\text{SNR}=18.8\text{ dB},\ \text{delay}=165\text{ ns})
3. Result
Rule agreement, forest87.9%one tree alone: 61.7%
Training accuracy96.7%
Vote share at P5 / 9 trees
The same sixty noisy links as the decision-tree lab. Every tree sees a different bootstrap sample and random features, so each draws a different, jagged map (small panels). The large panel shades the vote share v(x): deep colour means the trees agree. Agreement with the hidden rule usually rises as trees are added, then levels off.
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

Same data, six classifiers: which boundary fits the moons?

1. Formula and symbols
Acc=1N∑i=1N1[y^i=yi]\mathrm{Acc}=\frac1N\sum_{i=1}^{N}\mathbf 1[\widehat y_i=y_i]
gap=Acctrain−Accval\text{gap}=\mathrm{Acc}_{\rm train}-\mathrm{Acc}_{\rm val}
  • NN: Number of examples scored (80 training or 200 validation)
  • y^i\widehat y_i: Predicted class of example i
  • yiy_i: True class of example i
  • 1[⋅]\mathbf 1[\cdot]: 1 when the condition holds, else 0
  • gap\text{gap}: How much better the model does on data it has seen

All six models train on the same 80 points and are scored on 200 separate validation points from the same two-moons distribution.

RBF SVM: shaded regions · △ class 1 · ○ class 0Accuracy (axis from 50% to 100%)LogisticKNN (k=7)Tree (depth 5)Forest (25)RBF SVMNeural netgrey: train · colour: validation50%100%
Classifier
2. Work with the current inputs
y^=1[∑iαiyi(e−4∥x−xi∥2+1)≥0], C=3\widehat y=\mathbf1\big[\textstyle\sum_i\alpha_iy_i(e^{-4\lVert x-x_i\rVert^2}+1)\ge0\big],\ C=3
Acctrain=1.000,Accval=198200=0.990,gap=0.010\mathrm{Acc}_{\rm train}=1.000,\quad\mathrm{Acc}_{\rm val}=\tfrac{198}{200}=0.990,\quad\text{gap}=0.010
3. Result
RBF SVM validation accuracy99.0%
Training accuracy100.0%
Best on validationKNN (k=7)
Two interleaving half-moons with noise: a curved boundary is needed. Pick a model to see its decision regions; the bar chart compares all six on the same training and validation sets. Logistic regression can only draw a line; the tree draws steps; KNN, forests, the RBF SVM and the small neural network can bend. Fixed, untuned settings are used for every model.
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

Select the family on validation data, refit that choice on development data, then inspect the final test score once. This small example uses a single split; use fold-local pipelines for cross-validation.

from sklearn.base import clone
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_dev, X_test, y_dev, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42, stratify=y
)
X_train, X_validation, y_train, y_validation = train_test_split(
    X_dev, y_dev, test_size=0.25, random_state=43, stratify=y_dev
)

scores = {}
for name, clf in classifiers.items():
    candidate = make_pipeline(StandardScaler(), clone(clf))
    candidate.fit(X_train, y_train)
    pred = candidate.predict(X_validation)
    scores[name] = f1_score(y_validation, pred)
    print(name, "validation F1=", round(scores[name], 3))

best_name = max(scores, key=scores.get)
model = make_pipeline(StandardScaler(), clone(classifiers[best_name]))
model.fit(X_dev, y_dev)
pred = model.predict(X_test)
print("Selected:", best_name)
print("Final test accuracy:", accuracy_score(y_test, pred))
print("Final test F1:", f1_score(y_test, pred))
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.

Continue with Regression Algorithms to build on this note.

References for this section3

Check your understanding

0 of 4 answered

  1. Among 5 nearest neighbours, labels are 1, 0, 1, 1, 0. What does uniform KNN predict?

  2. A logistic score is z=0. What is sigmoid(z)?

  3. Which change directly alters Euclidean KNN distances?

  4. Which approach builds trees sequentially to improve the current objective?

Complete references and further reading