Do not skip this section!

This is where we'll introduce a bunch of fundamental concepts that carry into aspects of computer vision.

Image classification is arguably the quintessential problem in computer vision. Given an image, can you identify what it represents?

Classification models (i.e. *classifiers*) have been around for a long time. *Image* classifiers are just normal classification models designed to work with images.

## Framework¶

The general framework for any classification model is

- Predetermine a discrete set of classes (i.e.
*labels*) that the classifier should predict. For example`{ is_cat, not_cat }`

or`{ frog, turtle, snake }`

. - Design a model that, given a sample input, the model predicts which class the input represents (potentially with a probability score).
- Establish an evaluation metric that, given a collection of predictions and known truths, represents the performance of the model's predictions in numeric form.
- Implement an optimization process by which the model can change to increase its performance on known training data.

## Binary Classifier¶

A binary classifier predicts whether each sample input belongs to one of two classes.

**Examples**

- Is this a picture of a cat - Yes or No?
- This patient has cancer - True or False?
- What kind of food is on this plate - Hot dog or Not hot dog?

A binary model may output the predicted class label, but it's more common to output the *probability* of each class (or for brevity, just the probability of the positive class).

### Evaluation Metrics¶

The evaluation metric inputs the model's predictions and the corresponding known class labels and outputs a numeric score indicating how well the model performs.

Here are some common evaluation metrics used for binary classifiers:

### Loss Functions¶

Most machine learning models optimize their hyperparameters via gradient descent. The function that gradient descent optimizes is called a *loss function*.

Loss functions are just like evaluation metrics in that they input the model's predictions and corresponding known class labels and output a single score indicating the model's performance. However, **loss functions must be differentiable**, and therefor they are a subset of all evaluation metrics.

The most commonly used loss function for binary classifiers is Binary Cross Entropy.

If your evaluation metric is accuracy rate, what should be your loss function?

Your loss function should be Binary Cross-Entropy.

If your evaluation metric is Binary Cross-Entropy, what should be your loss function?

Your loss function should be Binary Cross-Entropy.

## Multiclass Classifier¶

A multiclass classifier predicts whether each sample input belongs to one of K ≥ 3 classes.

**Examples**

- What animal is in this picture - { mouse, cat, dog } ?
- What is this patient's diagnosis - { allergies, asthma, covid, flu, nothing, other } ?
- What kind of food is on this plate - { burger, hot dog, sandwich, steak } ?

### Evaluation Metrics¶

Evaluation metrics commonly used for multiclass classifiers include

### Loss Functions¶

The most commonly used loss function for multiclass classification is Cross Entropy.