成功解决RuntimeError: Selected KDE bandwidth is 0. Cannot estiamte density

简介: 成功解决RuntimeError: Selected KDE bandwidth is 0. Cannot estiamte density


目录

解决问题

解决思路

解决方法

1、重新定义bw参数

2、调试


解决问题

RuntimeError: Selected KDE bandwidth is 0. Cannot estiamte density.

 

解决思路

运行时错误:选择的KDE带宽为0。不能estiamte密度。

解决方法

推荐文章Py之seaborn:数据可视化seaborn库(一)的柱状图、箱线图(置信区间图)、散点图/折线图、核密度图/等高线图、盒形图/小提琴图/LV多框图的简介、使用方法之最强攻略(建议收藏)

出现此bug,是因为Seaborn库(它依赖的scipy或statmodels库来计算kde)没有办法计算出“bandwidth”,kdeplot函数中的bw参数,是一个缩放参数,当然也可以自定义。

1、重新定义bw参数

sns.kdeplot(ser_test, cumulative=True, bw=1.5)

2、调试

1. try:
2.     sns.distplot(df)
3. except RuntimeError as re:
4. if str(re).startswith("Selected KDE bandwidth is 0. Cannot estimate density."):
5.         sns.distplot(df, kde_kws={'bw': 0.1})
6. else:
7. raise re
8. 
9.

参考文章https://stackoverflow.com/questions/60596102/seaborn-selected-kde-bandwidth-is-0-cannot-estimate-density


相关文章
|
4月前
|
Ubuntu Linux Python
UserWarning: Glyph 27668 (\N{CJK UNIFIED IDEOGRAPH-6C14}) missing from current font.
UserWarning: Glyph 27668 (\N{CJK UNIFIED IDEOGRAPH-6C14}) missing from current font.
180 2
RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation.
RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation.
2511 0
|
6月前
|
算法 光互联 计算机视觉
Locally Adaptive Color Correction for Underwater Image Dehazing and Matching
该文提出了一种新颖的水下图像处理方法,结合颜色转移和局部调整来校正颜色,以应对水下光照和散射造成的图像退化。传统颜色转移方法基于全局参数,不适应水下场景中颜色变化的局部性质。文章中,作者通过融合策略,利用光衰减水平估计来实现局部颜色校正。首先,通过暗通道先验恢复彩色补偿图像,然后估计光衰减图。接着,创建一个合成图像,该图像的统计特性代表高衰减区域,用于颜色转移。最后,通过加权融合初始图像和颜色转移图像,生成最终的颜色校正图像。这种方法旨在提高水下图像的对比度和颜色准确性,特别关注高衰减区域。
63 1
|
机器学习/深度学习 PyTorch 算法框架/工具
【完美解决】RuntimeError: one of the variables needed for gradient computation has been modified by an inp
将loss.backward()函数内的参数retain_graph值设置为True, loss.backward(retain_graph=True),如果retain_graph设置为False,计算过程中的中间变量使用完即被释放掉。
1583 0
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
|
编解码 算法 数据挖掘
Density- and Grid-Based Methods|学习笔记
快速学习 Density- and Grid-Based Methods
Density- and Grid-Based Methods|学习笔记
Minimal Square
Minimal Square
87 0
Minimal Square
|
Web App开发
How to trouble shoot if there is no entityset available when creating a tile
How to trouble shoot if there is no entityset available when creating a tile
104 0
How to trouble shoot if there is no entityset available when creating a tile
|
数据可视化 Linux Python
成功解决RuntimeError: Selected KDE bandwidth is 0. Cannot estiamte density
成功解决RuntimeError: Selected KDE bandwidth is 0. Cannot estiamte density