Python - 将多项式拟合为 2 度,固定 x 截距为 0

问题描述

我正在尝试计算一组数据的方程,但将 x 截距固定为 0。我目前正在使用:

x,y = database_df[spend_name],database_df[media_name]
model = np.poly1d(np.polyfit(x,y,2))
polyline = np.linspace(0,max(database_df[spend_name]),50)
plt.plot(polyline,model(polyline),'--',color='red')
plt.scatter(x,y)

enter image description here

我需要能够将 x 截距设置为 0,以便能够在通过 0 时计算线的二次方。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)