+ 2

I'm getting Value error when building a model using anaconda

value error:found input variables with inconsistent numbers of samples:[1,178] The shape of both X and Y (train and test)are the same

14th Nov 2020, 10:37 PM
Dominic Mapakela Moyo
Dominic Mapakela Moyo - avatar
3 odpowiedzi
15th Nov 2020, 6:31 PM
Atul
Atul - avatar
0
I saw this solution but it's still not working their shapes are equal(i.e X and y) ,It's still outputing the same error
15th Nov 2020, 9:12 PM
Dominic Mapakela Moyo
Dominic Mapakela Moyo - avatar
0
Sounds like the shapes of your labels and predictions are not in alignment. I faced a similar problem while fitting a linear regression model . The problem in my case was, Number of rows in X was not equal to number of rows in y. In most case, x as your feature parameter and y as your predictor. But your feature parameter should not be 1D. So check the shape of x and if it is 1D, then convert it from 1D to 2D. x.reshape(-1,1) Also, you likely get problems because you remove rows containing nulls in X_train and y_train independent of each other. y_train probably has few, or no nulls and X_train probably has some. So when you remove a row in X_train and the same row is not removed in y_train it will cause your data to be unsynced and have different lenghts. Instead you should remove nulls before you separate X and y. http://net-informations.com/ds/mla/default.htm
14th Nov 2022, 6:17 AM
fostercarly