handson-ml2 icon indicating copy to clipboard operation
handson-ml2 copied to clipboard

[QUESTION][2nd Chapter] LinearRegression() - Value Error

Open Sunprince22 opened this issue 2 years ago • 1 comments

Hi sir, I have recently started reading your book and I'm in 2nd chapter now. till transformation pipeline I have got good knowledge and have implemented each line of code and practiced it as well.

But, coming to "Training and Evaluating on the Training Set" part, when I tried using linear regression an error is showing up by stating that "ValueError: Found input variables with inconsistent numbers of samples: [16512, 4128]"

from sklearn.linear_model import LinearRegression

lin_reg = LinearRegression()
lin_reg.fit(housing_prepared, housing_labels)

I'm not getting this issue and I'm stuck here, hope to hear back from you soon sir, Thank you

Sunprince22 avatar Jul 27 '22 00:07 Sunprince22

Your X is bigger than your Y. Post your code, otherwise no one can tell you what the bug is.

Roland-Pfeiffer avatar Jul 27 '22 21:07 Roland-Pfeiffer