Python中与R线性模型预测函数相当的是什么?

2024-09-28 20:50:47 发布

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

对于线性模型,Python等价于R predict函数是什么?在

我相信scipy中有一些东西可以帮到你,但是有没有一个等效的函数呢?在

https://stat.ethz.ch/R-manual/R-patched/library/stats/html/predict.lm.html


Tags: 函数https模型htmlstatslibrary线性scipy
1条回答
网友
1楼 · 发布于 2024-09-28 20:50:47

Scipy有大量的带有预测方法的回归工具;尽管IMO,Pandas是最接近复制R功能的python库,并带有预测方法。下面的R和python代码片段展示了它们的相似之处。在

R线性回归:

data(trees)
linmodel <- lm(Volume~., data = trees[1:20,])
linpred <- predict(linmodel, trees[21:31,])
plot(linpred, trees$Volume[21:31])

python中使用pandasols的相同数据集:

^{pr2}$

相关问题 更多 >