数据分布不均匀时,采用log变换处理数据,
plt.hist(np.log(df_train['cycle'].values), orientation = 'vertical',histtype = 'bar', color ='skyblue')
plt.show()
"""
ValueError: supplied range of [-inf, 5.572154032177765] is not finite
"""
这是因为你的数据中有0,经过log变化就是-inf(负无穷)
data=np.log(df_train['cycle'])
data
画图的时候就会报错,你可以让values+1
plt.hist(np.log(df_train['cycle'].values+1), orientation = 'vertical',histtype = 'bar', color ='skyblue')
plt.show()