【问题标题】:What is the source function of seaborn factorplotseaborn factorplot的源函数是什么
【发布时间】:2017-09-29 05:43:25
【问题描述】:

我是数据科学的新手。我对简单的 seaborn factorplot 有疑问。线段代表什么?

这是我的测试。

import pandas as pd
import seaborn as sns

x3 = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
y3 = [0, 1, 1, 1, 0, 3, 1, 0, 1, 1, 3, 2, 3, 2, 3, 3, 2, 3, 2, 2]
data = {'x': x3, 'y': y3}
test3 = pd.DataFrame(data)
sns.factorplot(x='Pclass', y='Survived', data=test3)

结果是

通过这个简单的测试,我知道图中的每个点都表示对于具有相同值的所有 x 值,y 的平均值(exp)。例如,当 x = 1 时,我们有 (1, 0)、(1, 3)、(1, 3) 和 (1, 3),所以均值是 (0 + 3 + 3 + 3) / 4 = 2.25。但是,我不知道为什么 x = 1 的线段是从 0.75 到 3.0,为什么不是 [0.0, 3.0]?

我试图在网上找到因子图源或任何有用的解释或文档,但没有好的结果。

谁能帮帮我,非常感谢。

【问题讨论】:

    标签: python pandas plot machine-learning seaborn


    【解决方案1】:

    我使用github repo 顶部的“搜索此存储库”搜索栏进行了调查。

    搜索“factorplot”导致我找到seaborn/categorical.pyclass _CategoricalPlotter(object),这导致我找到_BarPlotter(_CategoricalStatPlotter),它有文档字符串“”“显示点估计和带条的置信区间。”“”,它是@987654326 @包括self.estimate_statistic(estimator, ci, n_boot)

    estimate_statistic(self, estimator, ci, n_boot) 的函数定义位于class _CategoricalStatPlotter(_CategoricalPlotter) 中(仍在 categorical.py 文件中)。在那里,一个空列表confint(即置信区间)被初始化,并填充:

     boots = bootstrap(stat_data, func=estimator,
                                          n_boot=n_boot,
                                          units=unit_data)
     confint.append(utils.ci(boots, ci))
    

    所以你提到的垂直误差线是bootstrapped confidence intervals

    【讨论】:

      猜你喜欢
      • 2017-01-02
      • 2018-08-05
      • 2014-10-05
      • 1970-01-01
      • 2018-07-09
      • 2015-09-18
      • 1970-01-01
      • 2018-01-15
      • 1970-01-01
      相关资源
      最近更新 更多