21-General approach to classification, classification by decision tree induction-17-02-2025
21-General approach to classification, classification by decision tree induction-17-02-2025
Accuracy:
Accuracy in classification problems is the number of
correct predictions made by the model over all kinds
predictions made.
Accuracy
2. Confusion Matrix
The Confusion matrix is one of the most native and
easiest metrics used for finding the correctness and
accuracy of the model. It is used for Classification
problem where the output can be of two or more types
of classes.
Before diving into what the confusion matrix is all
about and what it conveys, Let’s say we are solving a
classification problem where we are predicting
whether a person is having cancer or not.
3. Precision:
Let’s use the same confusion matrix as the one we used
before for our cancer detection example.
Precision
Precision is a measure that tells us what proportion of
patients that we diagnosed as having cancer, actually
had cancer. The predicted positives (People predicted
as cancerous are TP and FP) and the people actually
having a cancer are TP.
4. Recall or Sensitivity:
Recall or Sensitivity
5. Specificity:
6. F1 Score:
We don’t really want to carry both Precision and Recall
in our pockets every time we make a model for solving
a classification problem. So it’s best if we can get a
single score that kind of represents both Precision(P)
and Recall(R).
# actual values
actual = [1,0,0,1,0,0,1,0,0,1]
# predicted values
predicted = [1,0,0,1,0,0,0,1,0,0]
# confusion matrix
matrix = confusion_matrix(actual,predicted,
labels=[1,0])
print('Confusion matrix : \n',matrix)