“Plot -Verwirrungsmatrix Scikit lernen” Code-Antworten

Sklearn -Plot -Verwirrungsmatrix

import matplotlib.pyplot as plt
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)         
# optional: 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() 
# plotting the confusion matrix
plot_confusion_matrix(clf, X, y)
plt.show()
wolf-like_hunter

Importieren Sie sklearn.metrics aus plot_confusion_matrix

from sklearn.metrics import plot_confusion_matrix
sbmthakur

Plot -Verwirrungsmatrix Scikit lernen

from sklearn import metrics
metrics.ConfusionMatrixDisplay.from_predictions(true_y, predicted_y).plot()
Arno Deceuninck

Ähnliche Antworten wie “Plot -Verwirrungsmatrix Scikit lernen”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen