传递给模型的参数奥利斯普雷迪

2024-09-28 01:27:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Old Faithful Geyser Dataset来学习一些线性回归和预测的入门知识。数据集包含两个特征:上次喷发后的时间和随后喷发的持续时间:

    eruptions   waiting
0   3.600   79
1   1.800   54
2   3.333   74
3   2.283   62
4   4.533   85

以下是汇总数据:

Old faithful dataset summary

模型如下:

^{pr2}$

当试图使用predict()进行预测时,我的问题就出现了。例如,如果我等了75分钟,这次喷发会持续多久?在

results.predict([1, 75]) # 1 needs to be passed, I don't know why

为什么通过1?是因为add_constant(X)添加了1?公司名称:

    const   waiting
0   1.0   79
1   1.0   54
2   1.0   74
3   1.0   62
4   1.0   85

docs说主要参数是“线性模型的参数” 唯一的变量是等待时间(75分钟),回归线有自己的截距(-1.87):

results.params
>>>
const     -1.874016
waiting    0.075628
dtype: float64

This answer注意到:

model.predict doesn't know about the parameters, and requires them in the call

但是如果是这样的话-1.87不是最好的论据吗?在

任何帮助都非常感谢。在


Tags: the数据模型时间线性特征predictresults

热门问题