我在 python 中有以下代码来创建 LinearRegression 模型。当我用重新采样的数据训练模型时,我得到了不同的系数值。我不明白为什么会这样。你能帮我吗?
[更新]
- 我假设重采样与改组相同。这意味着数据的顺序改变了,但数据本身没有改变。
- 在给出的用例中,行数与我检查的相同,据我所知,数据的顺序发生了变化。
谢谢!
from sklearn.linear_model import LinearRegression
from sklearn.utils import resample
model = LinearRegression(fit_intercept=False)
model.fit(X, y)
print('model.coef_',model.coef_)
model.fit(*resample(X, y))
print('model.coef_',model.coef_)
model.fit(*resample(X, y))
print('model.coef_',model.coef_)