presisi dan penarikan dari matriks kebingungan python

from sklearn.metrics import confusion_matrix, plot_confusion_matrix

clf = # define your classifier (Decision Tree, Random Forest etc.)
clf.fit(X, y) # fit your classifier

# make predictions with your classifier
y_pred = clf.predict(X) 
        
# get true negative (tn), false positive (fp)
# false negative (fn) and true positive (tp) 
# from confusion matrix
M = confusion_matrix(y, y_pred)
tn, fp, fn, tp = M.ravel() 

recall = tp / (tp + fn)       # definition of recall
precision = tp / (tp + fp)    # definition of precision
wolf-like_hunter