|
|
|
|
|
import seaborn as sns |
|
from sklearn.metrics import confusion_matrix |
|
import matplotlib.pyplot as plt |
|
from colorama import Fore,Back,Style |
|
|
|
|
|
def draw(y_true, y_pred): |
|
min_len = min( len(y_true), len(y_pred) ) |
|
|
|
sns.set() |
|
f, ax=plt.subplots() |
|
|
|
|
|
cm = confusion_matrix(y_true, y_pred, labels=[-1] * min_len) |
|
print(cm) |
|
sns.heatmap(cm, annot=True, ax=ax) |
|
|
|
def draw2(y_true, y_pred): |
|
min_len = min( len(y_true), len(y_pred) ) |
|
|
|
print('\t', end='') |
|
for i in range(min_len): |
|
y_true_format = str(y_true[i])[:3] |
|
print('%s\t' % y_true_format, end='') |
|
print('') |
|
|
|
for i in range(min_len): |
|
print(Fore.RESET + '%s\t' % str(i + 1), end='') |
|
for j in range(i): |
|
print('\t', end='') |
|
|
|
|
|
if y_pred[i] > 0.5: |
|
print(Fore.GREEN + str(y_pred[i])) |
|
else: |
|
print(Fore.RED + str(y_pred[i])) |
|
|
|
if __name__ == '__main__': |
|
draw2( [1.0] * 13, [0.5] * 13 ) |
|
|
|
|