Skip to main content
2 of 4
slight modification
karthiks
  • 352
  • 1
  • 2
  • 11

Why should re-sampling change the value of model's coefficients?

I have the code below in python to create LinearRegression model. When I train the model with re-sampled data, I get different values for its coefficients. I can't understand why that happens. Can you help me in this please? Thanks!

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_)
karthiks
  • 352
  • 1
  • 2
  • 11