Я пытаюсь создать путаницу в Python. Я могу создать матрицу путаницы, но она не поместит проценты в ячейку.
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
multiclass = np.array([[44.70, 30.83, 21.40, 2.67, 0.40],
[12.17, 64.10, 5.19, 18.34,0.21],
[11.63, 15.95, 43.64, 18.75, 10.02],
[4.89, 24.19, 14.32, 52.97, 3.53],
[0.00, 1.09, 5.38, 17.49, 76.03]])
class_names = ['apple','orange', 'tomato', 'melon', 'mango']
df_cm = pd.DataFrame(
multiclass, index=class_names, columns=class_names,
)
fig = plt.figure(figsize=(10,7))
try:
heatmap = sns.heatmap(df_cm, annot=True, fmt="d")
except ValueError:
raise ValueError("Confusion matrix values must be integers.")
heatmap.yaxis.set_ticklabels(heatmap.yaxis.get_ticklabels(), rotation=0, ha='right', fontsize=14)
heatmap.xaxis.set_ticklabels(heatmap.xaxis.get_ticklabels(), rotation=45, ha='right', fontsize=14)
plt.ylabel('True label')
plt.xlabel('Predicted label')
Что я хочу сделать, так это распечатать значения в каждой ячейке на матрице путаницы. Как это можно сделать? Помощь будет оценена.