# coding:utf-8 import pandas as pd import numpy as np import matplotlib.pyplot as plt # one_hot數據的讀取 label = pd.read_csv(r'./test/y_pred.csv',header=0,index_col=0) y_test = pd.read_csv(r'./test/y_test.csv',header=0,index_col=0) label = label.values print(label.shape) x = np.zeros([len(label[:,0])]).reshape(-1,1) print(x.shape) n,m = label.shape x = np.argmax(label,axis=1).reshape(-1,1) print(np.max(x)) y = np.array(y_test.values).reshape(-1,1) print(np.max(y)) source = len((x-y)[(x-y)==0])/len(x) plt.figure('tensorflow-手寫數字',figsize=(12,6)) plt.scatter(list(range(len(x))),x,c=y,label='source={0}'.format(source)) font_size = {'size':15} plt.title('one_hot-label',font_size) plt.xlabel('第i個數字',font_size) plt.ylabel('數字類別',font_size) plt.legend(loc='upper left') plt.axis([0,530,0,10]) xlabel = ['數字0','數字1','數字2','數組3','數字4','數字5','數字6','數字7','數字8','數字9'] plt.xticks(range(0,501,100),['第0個','第100個','第200個','第300個','第400個','第500個']) plt.yticks(range(10),xlabel) plt.rcParams['font.sans-serif'] = ['SimHei'] # 設置字體為SimHei顯示中文 plt.rcParams['axes.unicode_minus'] = False # 設置正常顯示符號 plt.show()