seaborn factorplot的源函数是什么
What is the source function of seaborn factorplot
我是数据科学的新手。我有一个关于简单的 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]?
我试图在网上找到 factorplot 源或任何有用的解释或文档,但没有很好的结果。
谁能帮帮我,非常感谢
我使用 github repo 顶部的 "search this repository" 搜索栏对此进行了调查。
搜索 "factorplot" 让我找到 seaborn/categorical.py
和 class _CategoricalPlotter(object)
,这让我找到 _BarPlotter(_CategoricalStatPlotter)
,它有文档字符串“"Show point estimates and confidence intervals with bars."”, __init__
包括 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。
我是数据科学的新手。我有一个关于简单的 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]?
我试图在网上找到 factorplot 源或任何有用的解释或文档,但没有很好的结果。
谁能帮帮我,非常感谢
我使用 github repo 顶部的 "search this repository" 搜索栏对此进行了调查。
搜索 "factorplot" 让我找到 seaborn/categorical.py
和 class _CategoricalPlotter(object)
,这让我找到 _BarPlotter(_CategoricalStatPlotter)
,它有文档字符串“"Show point estimates and confidence intervals with bars."”, __init__
包括 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。