Greetings!
Today is Chinese New Year’s day in Seoul, 4 days of holidays from Jan 24 to Jan 27, 2020. People go to their hometowns to meet their parents, and relatives and to have good family time together. However, as I made up a story that I am super busy with work, I did not have to participate in those meetings(Please don’t tell my auntie). So while having a restful day, I decided to study things and to share those with you!
I was building a classification model using Scikit-Learn.
This is perhaps the most widely used machine learning library in Python.
After finishing to build the model, and to check the performance of it, I printed out the ‘Classification Report’ which is provided as a method within Scikit-learn under the category of ‘metrics’. It looks like this.
Classification report:
precision recall f1-score support en 0.67 1.00 0.80 2
fr 1.00 1.00 1.00 2
id 1.00 0.50 0.67 2 accuracy 0.83 6
macro avg 0.89 0.83 0.82 6
weighted avg 0.89 0.83 0.82 6
Before diving into interpreting this table, we need to know about the ‘Confusion matrix’, which looks like below.
- Precision
An ability of a classifier not to label positive to the negatives
When you say a male is pregnant, which is not possible yet, then this would be detected under this precision score.
(Number of true positive cases) / (Number of all the positive cases)
*all the positive classes = true positive + false positive - Recall
An ability of a classifier to find all positive instances. So, only corrected measured instances, which are true-positive and false-negatives, are concerned.
(Number of true positives) / (# of true positives + # of false negatives)
*# signifies ‘number’
By far, we can tell both Precision and Recall focus on true-positive cases in different perspectives. - F1-score
This is a weighted harmonic mean value using both Precision and Recall. This measure is pretty useful when the dataset has an imbalanced distribution of different labels.
{(Precision * Recall) * 2} / (Precision + Recall) - Support
This is rather a simple counting. Support is the number of occurrences of each class label in the *y_test* dataset. In my test data, there were each of 2 files of each different three languages, English, French, and Indian. Thereby each class support number is 2.
So, as we have studied these intimidating four terms together, we no longer have to fear about the table!
Easy-peasy huh?! 🍝 🍰 ✨
Happy learning!