我是靠谱客的博主 热心巨人,这篇文章主要介绍python报错ValueError: supplied range of [-inf, 5.572154032177765] is not finite,现在分享给大家,希望可以做个参考。

数据分布不均匀时,采用log变换处理数据,

复制代码
1
2
3
4
5
6
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(负无穷)

复制代码
1
2
3
data=np.log(df_train['cycle']) data

在这里插入图片描述画图的时候就会报错,你可以让values+1

复制代码
1
2
3
plt.hist(np.log(df_train['cycle'].values+1), orientation = 'vertical',histtype = 'bar', color ='skyblue') plt.show()

在这里插入图片描述

最后

以上就是热心巨人最近收集整理的关于python报错ValueError: supplied range of [-inf, 5.572154032177765] is not finite的全部内容,更多相关python报错ValueError:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(87)

评论列表共有 0 条评论

立即
投稿
返回
顶部