Reputation: 68
There is a Naive Bayesian classifier which is created with a given training data. In the table, the predicted positive class probabilities and the actual class labels are shown. I want to prepare the confusion matrix but I could not find out how to do it with just knowing the probabilities.
ID | Actual class label | Predicted positive class probability |
---|---|---|
1 | + | 0.6 |
2 | + | 0.8 |
3 | - | 0.2 |
4 | + | 0.3 |
5 | - | 0.4 |
Upvotes: 1
Views: 649
Reputation: 333
First, you need to have discrete class labels to compute confusion matrix. Define a threshold on the predicted positive class probability to predict class labels (y_pred). You can then use actual class labels (y_actual) and y_pred to compute the confusion matrix.
from sklearn.metrics import confusion_matrix
confusion_matrix(y_actual, y_pred)
Upvotes: 1