python - 从多项式回归(图)获取函数 ("f(x)")

标签 python numpy matplotlib regression integration

我对一些数据进行了多项式回归。 绘制了图表。但是如何获得绘制图形的函数“f(x)”呢?我喜欢集成该功能!

 z = np.polyfit(x, y1, 6)  
 p = np.poly1d(z) 

 xp = np.linspace(0, 1, 100)
 line = plt.plot(x, y1, '.', xp, p(xp), '-', label=' G_MEAN_1 ')
 plt.ylim(0, 1)
 plt.legend()
 plt.show()

那么我怎样才能从这里获取该功能 - 进行集成?

最佳答案

作为

    p = np.poly1d(z) 

返回一个函数,可以使用“p”进行积分。因此,要获得 0.3 到 0.6 的积分形式,您可以通过:

integrate.quad(p, 0.3, 0.6)

关于python - 从多项式回归(图)获取函数 ("f(x)"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56782110/

相关文章:

python - 如何使 QTableWidget 中的单元格只读?

python - 以矢量化方式连接给定开始、结束数字的范围数组 - NumPy

python - 将纹理映射到 mayavi 网格

matplotlib - Matplotlib 轴如何按双曲线缩放?

python - matplotlib:可以改变背景颜色吗?

python - Python 中的 Violin Plot 在对数尺度上的问题

python - unicorn worker 被杀

python - 调整两个 Jupyter 小部件之间的间距

python - 用于定位文本区域元素的 Selenium 脚本不起作用

python - Python 中的高效二维边缘检测