You can use the scikit-learn library in Python to create a confusion matrix. Here's an example code snippet:
from sklearn.metrics import confusion_matrix
# Assuming you have true labels and predicted labels
true_labels = [0, 1, 0, 1, 1, 0]
predicted_labels = [0, 1, 1, 1, 0, 0]
# Create a confusion matrix
cm = confusion_matrix(true_labels, predicted_labels)
print(cm)
This code will output the confusion matrix in the form of a 2x2 array:
[[2 1]
[1 2]]