Multiclass Classification

Classification of targets with more than two labels

  • SVC handles multiclass classification
  • KNeighborsClassifier also handles multiple classes
  • LogisticRegression does handle multiple classes as well

Case study

Download this dermatology data and fit SVC to it

Classification Metrics

For precision, recall, and F1 score we have three options:

  • macro – arithmetic/unweighted mean
  • micro – global, sums True Positives (TP), False Negatives (FN), and False Positives (FP)
  • weighted – weighted mean, considering the number of occurrences for each class
print(f1_score(y_test, y_pred, average='macro')) 

Classification Metrics

  • zero-one loss function – fraction of misclassifications – loss of 0 if the prediction is correct and 1 for incorrect
  • returns the fraction of misclassifications by default
  • set normalize=False for count of missclassification cases
from sklearn.metrics import zero_one_loss
zero_one_loss(y_test, y_pred)

Classification Report

from sklearn.metrics import classification_report
classification_report(y_test, y_pred)