Frank Jimenez
Frank Jimenez

Reputation: 369

Scikit-learn: getting same result on all rows when reusing the model

So I want to figure out some GDP numbers from a country's GDP primary industry. The earliest data does not have any GDP values so I have trained a model with newer data. My plan is to use that trained model to guess older data.

I then fed new data to the model (the older data) but the model predicts the same number value for all the years!

What am I doing wrong?

PS. I only started with ML so apologies for messy code/ml technique :(

EDIT: FIXED. The new data needed to be scaled too :)

enter image description here

Upvotes: 0

Views: 244

Answers (2)

ayoubft
ayoubft

Reputation: 1

Try using sklearn Pipelines (also here) to take care of rescaling the data before new use for you.

Upvotes: 0

anthony-khong
anthony-khong

Reputation: 131

I believe you need to call sc.transform on X1 as well. Otherwise, the scale of the features would be off, and the predictions become erroneous too.

Upvotes: 3

Related Questions