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

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

解决问题


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、调试


try:

   sns.distplot(df)

except RuntimeError as re:

   if str(re).startswith("Selected KDE bandwidth is 0. Cannot estimate density."):

       sns.distplot(df, kde_kws={'bw': 0.1})

   else:

       raise re


相关文章
|
3月前
|
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.
148 2
|
4月前
|
C++
C++中的setprecision: fixed: scientific等函数
C++中的setprecision: fixed: scientific等函数
33 0
|
机器学习/深度学习 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,计算过程中的中间变量使用完即被释放掉。
1527 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
74 0
Minimal Square
|
数据可视化 Linux Python
成功解决RuntimeError: Selected KDE bandwidth is 0. Cannot estiamte density
成功解决RuntimeError: Selected KDE bandwidth is 0. Cannot estiamte density
问题 B: Scaling Recipe
你有一个食谱,其中指定了一些食材,你需要的每种食材的数量,以及它产生的分量。但是,你需要的份量和食谱中指定的份量不一样!你如何衡量它?
97 0
|
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
How to trouble shoot if there is no entityset available when creating a tile