【发布时间】:2023-01-04 20:00:15
【问题描述】:
我有一个 pandas df,看起来像这样(缩放后):
Age blood_Press golucse Cholesterol
0 1.953859 -1.444088 -1.086684 -1.981315
1 0.357992 -0.123270 -0.585981 0.934929
2 0.997219 0.998712 2.005212 0.019169
3 2.589318 -0.528543 -1.123484 -1.299904
4 2.088141 0.792976 0.021526 -0.777959
和一个二元目标特征:
y
0 1.0
1 1.0
2 1.0
3 0.0
4 1.0
我想用 y 目标为每个预测特征制作一个条形图。所以 y 值将在 x 轴上,即 1 或 0,而在 y 轴上将是预测特征的值。例如,看起来像这样的东西(忽略这里使用的功能,只是我需要的一个例子)。所以这里不是male和female,而是1和0...
这个情节的代码是这样的:
myPlot = sns.catplot(data = data, x = 'the y feature' , y = 'the x feature', kind = 'bar')
myPlot.fig.suptitle('title title', size=15, y=1.);
myPlot.set_ylabels('Y label whatever', fontsize=15, x=1.02)
myPlot.fig.set_size_inches(9,8);
但我不想对每个功能都重复它,我相信它比那简单得多。但是怎么办?
【问题讨论】:
标签: python pandas matplotlib seaborn