可视化操作是工程师必备技能。在算法开发中,可视化能够辅助调试。本文对pyplot绘制柱形图做记录。
今天我欲对se_net中权重的学习情况进行可视化研究,从而判断出哪个通道/特征占据主导因素。其中使用pyplot进行可视化。jupyter notebook代码如下:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
#se权重
outputs = [0.9999635, 0.8995363, 0.13885525, 0.12847622, 0.11337245, 0.11435881,0.11065625, 0.11901541, 0.11137064, 0.14423777, 0.99997544, 0.02447405,0.03595051, 0.02142572, 0.02746158, 0.01961504, 0.03209742, 0.02768629,0.0280421]
#特征标签
tags = ["n_points","speed","north","northeast","east","sourtheast","sourth","sourthwest","west","northwest","line_number","line_north","line_northeast","line_east","line_sourtheast","line_sourth","line_sourthwest","line_west","line_northwest"]fig,ax=plt.subplots()
ax.bar([i+1 for i in range(19)],outputs, width=0.5)
ax.set_xlabel("feature") #设置x轴标签
ax.set_ylabel("importance") #设置y轴标签
ax.set_title("feature importance") #设置标题
#添加x坐标对应的label
plt.xticks([i+1 for i in range(19)],tags,rotation=90)
plt.show() #显示图像