成功解决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
目錄
解決問題
解決思路
解決方法
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、調試
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?參考文章:https://stackoverflow.com/questions/60596102/seaborn-selected-kde-bandwidth-is-0-cannot-estimate-density
總結
以上是生活随笔為你收集整理的成功解决RuntimeError: Selected KDE bandwidth is 0. Cannot estiamte density的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 成功解决TypeError: data
- 下一篇: Python之pandas:数据类型变换
