【发布时间】:2021-07-11 05:03:50
【问题描述】:
为了拟合,我正在使用带有加权值的 sklearn LinearRegression:
from sklearn.linear_model import LinearRegression
regr = LinearRegression()
regr.fit(x, y, w)
plt.scatter(x, y, color='black')
plt.plot(x, regr.predict(x), color='blue', linewidth=3)
但是,现在我的数据显示的不是线性行为,而是二次行为。所以我尝试实现 polynomicFeatures:
from sklearn.preprocessing import PolynomialFeatures
regr = PolynomialFeatures()
regr.fit(x, y, w)
plt.scatter(x, y, color='black')
plt.plot(x, regr.predict(x), color='blue', linewidth=3)
但是,PolynomialFeatures 拟合函数似乎不允许在其拟合函数中使用 sample_weight 参数。有没有办法使用多项式拟合的权重?
【问题讨论】:
标签: scikit-learn