直方圖的bins參數使用功能?
2019/05/03 下午 05:41
機器學習共學討論版
Liang-Yu, Cheng
觀看數:95
回答數:2
收藏數:1
ml100-2
bins
histogram
ml100-2-d05
回答列表
-
2019/05/03 下午 07:07Jimmy贊同數:4不贊同數:0留言數:0
Hi
要回答這個問題,我們可以先來看 bins 這個參數的意義,從 matplotlib 的官方文件提到
If an integer is given,
bins+1
bin edges are calculated and returned, consistent withnumpy.histogram
而 numpy.histogram 則是說:
If bins is an int, it defines the number of equal-width bins in the given range (10, by default).
意思是說當你今天設定 bins =10,會自動幫你把資料數值切成 10 等分,然後統計每一個數值內的資料數量。bins 的數量設置越小,得到的 histogram 圖就會越粗糙,反之則會越精細。
建議你可以從預設值開始逐步增加,畫 histogram 的重點是要透過視覺化來了解你的資料分布是什麼 (是否為常態分佈?偏態分佈?) ,適當的 bins 值才能幫助你更快的了解資料分布。你可以從這裡看到各種 bins 值畫出來的圖。
希望能夠回答到您的問題,有任何問題歡迎隨時提問喔,謝謝:)
-
2019/05/03 下午 07:08Seanyu.TW贊同數:2不贊同數:0留言數:0
Hi, bins 代表你要用的 historgram 要切成幾根。想知道更細的解釋可以參考 https://www.cnblogs.com/python-life/articles/6084059.html