python - Statsmodel 奇怪的行为
问题描述
我在 python 中使用 statsmodels 来执行分位数回归。我正在运行分位数 99 和分位数 1 来查看我的分布的极端分位数。
from statsmodels.regression.quantile_regression import QuantReg
from sklearn.datasets import load_iris
import pandas as pd
iris = pd.DataFrame(load_iris()['data'])
y = iris[0]
x = iris.iloc[:, [1, 2, 3]]
qt = QuantReg(y, x)
res99 = qt.fit(q=.99)
res01 = qt.fit(q=.01)
print('Quantile 99 description')
print(res99.predict(x).describe())
print('--------------------')
print('Quantile 01 description')
print(res01.predict(x).describe())
print('--------------------')
print('Target description')
print(y.describe())
输出是
Quantile 99 description
count 150.000000
mean 6.713570
std 1.092909
min 3.972447
25% 5.798665
50% 6.745737
75% 7.447919
max 9.906085
dtype: float64
--------------------
Quantile 01 description
count 150.000000
mean 5.196659
std 0.811265
min 3.110156
25% 4.555466
50% 5.270011
75% 5.777980
max 7.588576
dtype: float64
--------------------
Target description
count 150.000000
mean 5.843333
std 0.828066
min 4.300000
25% 5.100000
50% 5.800000
75% 6.400000
max 7.900000
Name: 0, dtype: float64
也就是说,百分位数 1、目标和百分位数 99 的分布并没有太大的不同。这是预期的还是我错过了什么?
解决方案
推荐阅读
- google-chrome - 如何从命令行更改铬(谷歌浏览器)的用户代理?
- ffmpeg - 使用 ffmpeg 将 rtsp 流式传输到 rtmp 时丢失数据包错误
- vb.net - 如何使用类似于 Spy++ 64 日志消息的 Windows API 在 VB.Net 中捕获另一个应用程序的消息
- javascript - 当实际上没有要添加的值时,向 Object 值添加值
- python - Pandas Dataframe - 按 Col A 分组并对每个组 Col C 求和
- jmeter - 基本 Jmeter 负载测试:10k 不同用户并发登录。所有 10k 用户都应该先在系统中注册吗?
- reactjs - React.default.memo 不是一个函数 (React-Native) wrapWithConnect
- python-3.x - CloudFormation 堆栈删除无法删除 VPC
- facebook - 使用 Firebase 动态链接分享到 Facebook 时无法预览
- javascript - 未捕获的 referenceError 变量未定义