# 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?

[Update]

• I assume that resampling is the same as shuffling. And that means the order of the data is changed but not the data itself.
• In the use case presented, the number of rows are are the same as I inspected it and as I understand the order of the data is changed.

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_)

• The resampled data is not identical to your original dataset (it is done with replacement by default). Why would you expect to get the same coefficients training on different data? They should be roughly similar, but not identical. – Nuclear Hoagie Jul 18 '18 at 17:41
• @NuclearWang, resampling is just shuffling the existing data. So the only thing that changes is order of the data and not the data itself, right? – karthiks Jul 18 '18 at 17:44
• No, by default the resampling is performed with replacement, so it's highly likely that your resampled data has repeated data points. If you did a full resampling without replacement, then yes, you'd have a shuffled version of your original data. – Nuclear Hoagie Jul 18 '18 at 18:16
• @NuclearWang My bad in mis-reading scikit docs for shuffle() to assume it is an alias for resample(), without looking into the details. You explanation makes sense. Thanks! – karthiks Jul 18 '18 at 18:22