我用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
以下是汇总数据:
模型如下:
^{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不是最好的论据吗?在
任何帮助都非常感谢。在
您正在学习}(b是偏差项)
传递两个值x=75,b的乘数为1。在
y = Ax + b
形式的方程的参数 你的模型说A = 0.075628
和{你也可以运行predict as,
results.predict(sm.add_constant([75], has_constant='add'))
相关问题 更多 >
编程相关推荐