To create a confusion matrix in Python, we can use the confusion_matrix()
function from the scikit-learn library. Here's an example:
main.py236 chars13 lines
Output:
main.py31 chars3 lines
In this example, we have two classes (0 and 1). The confusion matrix tells us the number of true positives, false positives, true negatives, and false negatives for each class. In this case, we have:
We can interpret the confusion matrix to evaluate the performance of our machine learning model.
gistlibby LogSnag