[英]How to plot density plot by label (categorical variable) for each numeric column?
我嘗試使用地雷和岩石數據( http://archive.ics.uci.edu/ml/datasets/connectionist+bench+(sonar,+mines+vs.+rocks) )進行EDA。 我放置了以下代碼,可以繪制每個數字列的密度圖。
有沒有一種方法可以為數據集中的每個數字變量繪制相同的圖表,但是根據密度是M還是R(最后一列),每個密度圖中有兩條線。 因此,我們可以看到哪個變量顯示了標簽M與R的不同分布。
import pandas as pd
# import file
file = 'https://archive.ics.uci.edu/ml/machine-learning-
databases/undocumented/connectionist-bench/sonar/sonar.all-data'
mr_df = pd.read_table(file, sep=',', header=None)
mr_df.plot(kind='density', subplots=True, layout=(8,8), sharex=False, legend=False, fontsize=1, figsize=(12,12))
plt.savefig('density plot.png')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.