“Kod Python Matrix Confusion” Kod odpowiedzi

Matryca zamieszania Python

from sklearn.metrics import confusion_matrix
conf_mat = confusion_matrix(y_test, y_pred)
sns.heatmap(conf_mat, square=True, annot=True, cmap='Blues', fmt='d', cbar=False)
Adventurous Addax

Python plot_confusion_matrix

from sklearn.metrics import confusion_matrix
cm = confusion_matrix(test_Y, predictions_dt)
cm
# after creating the confusion matrix, for better understaning plot the cm.
import seaborn as sn
plt.figure(figsize = (10,8))
# were 'cmap' is used to set the accent colour
sn.heatmap(cm, annot=True, cmap= 'flare',  fmt='d', cbar=True)
plt.xlabel('Predicted_Label')
plt.ylabel('Truth_Label')
plt.title('Confusion Matrix - Decision Tree')
Khola GenZ

Matryca zamieszania Python

By definition, entry i,j in a confusion matrix is the number of 
observations actually in group i, but predicted to be in group j. 
Scikit-Learn provides a confusion_matrix function:

from sklearn.metrics import confusion_matrix
y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]
y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]
confusion_matrix(y_actu, y_pred)
# Output
# array([[3, 0, 0],
#        [0, 1, 2],
#        [2, 1, 3]], dtype=int64)
Bored Coder

Kod Python Matrix Confusion

from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_predicted)
cm
# after creating the confusion matrix, for better understaning plot the cm.
import seaborn as sn
plt.figure(figsize = (10,7))
sn.heatmap(cm, annot=True)
plt.xlabel('Predicted')
plt.ylabel('Truth')
Clumsy Cowfish

Matryca zamieszania Python

df_confusion = pd.crosstab(y_actu, y_pred, rownames=['Actual'], colnames=['Predicted'], margins=True)
Bad Bison

Jak uzyskać matrycę zamieszania w Pythonie

from sklearn.metrics import confusion_matrix
conf_mat = confusion_matrix(y_test, y_pred)
Colorful Copperhead

Odpowiedzi podobne do “Kod Python Matrix Confusion”

Pytania podobne do “Kod Python Matrix Confusion”

Więcej pokrewnych odpowiedzi na “Kod Python Matrix Confusion” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu