python-3.x - 面网格和点图没有给出准确的结果
问题描述
我正在使用Kaggle的 Titanic 数据集。我试图可视化所有分类变量之间的相关性。为此,我将点图与 FaceGrid 一起使用。图的某些部分与数据相矛盾。
为了生成点图,我使用了
grid = sns.FacetGrid(train, row='Embarked', size=2.2, aspect=1.6)
grid.map(sns.pointplot, 'Pclass', 'Survived', 'Sex', palette='deep')
grid.add_legend()
点图显示,几乎所有从“C”出发且 Pclass =1 和 2 的男性都幸存了下来。这是极不可能的。我尝试使用数据透视表对其进行验证:
temp = round(pd.pivot_table(train_df, values='Survived', index=['Embarked','Sex'], columns='Pclass', aggfunc=[lambda x: len(x), np.sum,'mean'] ),2)
1班42人,2班10人,3班43人从'C'出发。
但只有 17、2、10 人幸存下来。因此,平均概率应为 0.40、0.20 和 0.23。
我认为主要问题是它产生的警告:
UserWarning: Using the pointplot function without specifying `order` is likely to produce an incorrect plot.
UserWarning: Using the pointplot function without specifying `hue_order` is likely to produce an incorrect plot.
我不明白Order这里的意思。附带说明:如何对 Embarked 索引进行排序以说出“S”、“C”和“Q”。
解决方案
推荐阅读
- r - 我需要通过用另一列中的值填充 R 中两行之间的日期来拉长数据集
- dataweave - 通过组合字段重新格式化 XML 有效负载
- dataframe - 我对axis = 0和axis = 1感到困惑
- jquery - jQuery 在迷你购物车 WooCommerce 中无法正常工作
- mysql - 当我使用 Mysql 时,没有在启动时创建 Camunda 表
- javascript - 使用 async/await 加载库对象
- javascript - 使用日期和月份验证出生日期,如果 18 岁也可以注册
- amazon-dynamodb - Dynamo - 写入期间增加读取延迟
- xcode - CDN:无法下载中继 URL:https://cdn.jsdelivr.net/cocoa/Specs/1/d/4/CocoaAsyncSocket/7.6.1/CocoaAsyncSocket.podspec.json
- r - 减少相交故障排除