# Classification

## Classification

Classification is the process of identifying an object from a possible set of results. For instance, suppose that a bag has apples and oranges, the process of classification is to separate the apples in one bag and the oranges in other bag. In this case, the problem has two classes: class 1 (apple), and class 2 (orange). In the figure below, the classifier has two light bulbs used to identify the input object. When an apple is at the input of the classifier, the class 1 bulb is on. When an orange is at the input of the classifier, the class 2 bulb is on. ## Reject class

In some cases, the experiment has one or more classes that are not of interest. For instance, in the example of the bags with apples and oranges, consider that the bag has also pineapples. However, the experiment consists on separating the apples in one bag, and the oranges in other bag while ignoring the pineapples. In this case, the reject class is pineapple. In the figure below, neither of the light bulbs turns on when the pineapple is at the input of the classifier. Tip An artificial neural network can be trained for classification, that is, to identity and separate different kinds of objects. These objects can be: numbers, images, sounds, signals, etc.

## Classifier

The number of outputs of an ANN, in classifier configuration, is equal to the number of classes in the experiment. For instance, if an ANN is used to separate apples and oranges, the ANN must have two outputs.

## Confusion Matrix

A confusion matrix is used in classification to indicate the performance of the classifier. If there are m classes, the confusion matrix has m+1 rows and m+1 columns. This matrix indicates how many objects were correctly classified. When the classifier identifies correctly all objects, the confusion matrix is diagonal. The row number (in a confusion matrix) indicates the class number. On the other hand, the column number indicates the classifier result. Thus, if an element is correctly classified, the row number and the column number must be equal.

 Tip The confusion matrix is used to report visually the results of a classification problem. For instance, in the figure below, there are four apples (class 1) classified as class 1 represented by the number four in the first cell of the matrix. The number three (in the second row) represents three elements in class 2 (oranges) correctly classify as class 2. Finally, the number one in the third row represents the only pineapple in the reject class. Tip The confusion matrix should ideally have one and only one non-zero element in each row. In the case that the matrix has a non-zero element outside of the main diagonal, this indicates that the classifier has misclassified some of the objects. The last column of this matrix is used for the reject class, and indicates the number of objects that the classifier was not able to classify. In the figure, one of the apples was incorrectly classified as class 2, and one apple was not classified at all. In the same figure, one orange was correctly classified and two oranges were not classified. 