Classification

التصنيف

Definition

A supervised learning task in which the model predicts a discrete class (label) for each input, such as “spam” or “not spam”.

Definition

Classification is a supervised learning task in which a model learns to assign each input to one of a set of discrete categories, based on labelled training examples.

Practical examples

Code example Python
from sklearn.metrics import precision_score, recall_score, f1_score

y_true = [1, 1, 1, 0, 0, 1, 0, 1]
y_pred = [1, 0, 1, 0, 1, 1, 0, 0]
print(precision_score(y_true, y_pred), recall_score(y_true, y_pred), round(f1_score(y_true, y_pred), 3))

Expected output

0.75 0.6 0.667

Mathematical equations

F_1 = 2\cdot\frac{\text{Precision}\cdot\text{Recall}}{\text{Precision}+\text{Recall}}, \quad \text{Precision}=\frac{TP}{TP+FP}, \quad \text{Recall}=\frac{TP}{TP+FN}

Scientific sources

References and scientific sources

  • Book
    The Elements of Statistical Learning (2nd ed.) Trevor Hastie, Robert Tibshirani, Jerome Friedman · 2009 · Springer A statistical reference on machine learning, freely available from the authors' website.
  • Book
    Pattern Recognition and Machine Learning Christopher M. Bishop · 2006 · Springer A classic reference on probabilistic machine learning.

Learn and review

Suggested terms to learn next