使用python进行多项式回归 [英] polynomial regression using python

查看:108
本文介绍了使用python进行多项式回归的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,多项式回归是一种特定类型的回归分析,它比线性回归更为复杂. 是否有可以执行此操作的python模块? 我查看了matplotlib,scikitand numpy,但只能找到线性回归分析.

From what i understand polynomial regression is a specific type of regression analysis, which is more complicated than linear regression. Is there a python module which can do this? I have looked in matplotlib ,scikitand numpy but can only find linear regression analysis.

有可能算出非线性线的相关系数吗?

And it is possible to work out the correlation coefficient of a none linear line?

推荐答案

您看过NumPy的polyfit吗?参见参考.

Have you had a look at NumPy's polyfit? See reference.

从他们的示例中:

>>> import numpy as np
>>> x = np.array([0.0, 1.0, 2.0, 3.0,  4.0,  5.0])
>>> y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0])
>>> z = np.polyfit(x, y, 3)
>>> z
[ 0.08703704 -0.81349206  1.69312169 -0.03968254]

这篇关于使用python进行多项式回归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆