Found input variables with inconsistent numbers of samples

0 votes

Hi All,

I am implementing linear regression by Extract the rating as to your target variable ‘y’ and all numerical parameters as your predictors ‘x’. Please find the below steps taken by me
read the CSV into data frame df
extracted 'rating' into y

y=df['rating'].values
df_1=df
df_1.drop(['name','mfr','type','ManufacturerFullName'], axis=1, inplace=True)
df_1.drop(['rating'], axis=1, inplace=True)
x=df_1.values
from sklearn.model_selection import train_test_split
x_train, y_train, x_test, y_test=train_test_split(x,y_rating,test_size=0.75)
from sklearn.linear_model import LinearRegression
model=LinearRegression()
model.fit(x_train,y_train)
Jul 12, 2020 in Machine Learning by sagar
• 120 points

edited Jul 13, 2020 by MD 2,325 views

1 answer to this question.

0 votes

Hi@sagar,

You have converted your Dataframe into an array. You don't need to do this. In your code, you don't have y_rating. But you used this variable. I suggest you first, design your model in your mind what you want. If you will get the same issue, then paste your full code along with the error.

answered Jul 13, 2020 by MD
• 95,040 points

Related Questions In Machine Learning

0 votes
2 answers
0 votes
0 answers

ValueError: Found input variables with inconsistent numbers of samples: [11, 3988]

After reshaping also I am getting the ...READ MORE

Aug 27, 2020 in Machine Learning by sairam
• 160 points

edited Aug 27, 2020 by MD 1,309 views
0 votes
1 answer

ValueError: Found input variables with inconsistent numbers of samples: [616, 308]

Hi@Alshwarya, I think there is a problem with your ...READ MORE

answered Sep 23, 2020 in Machine Learning by MD
• 95,040 points
362 views
0 votes
1 answer
0 votes
1 answer

What are the options for deploying models in production with R?

Well, I could say that the answer ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,240 points
755 views
0 votes
1 answer

Use different distance formula other than euclidean distance in k means

K-means is based on variance minimization. The sum-of-variance formula ...READ MORE

answered Jun 21, 2018 in Data Analytics by Sahiti
• 6,360 points
708 views
0 votes
1 answer

Overfitting vs Underfitting

In statistics and machine learning, one of ...READ MORE

answered Jul 11, 2018 in Data Analytics by CodingByHeart77
• 3,720 points
205 views
+1 vote
1 answer

How to handle Nominal Data?

Nominal data is basically data which can ...READ MORE

answered Jul 23, 2018 in Data Analytics by Abhi
• 3,720 points
130 views
+1 vote
1 answer
0 votes
1 answer

problem with Found input variables with inconsistent numbers of samples: [1204, 134]

Hi@Alessandro, Here you used x as your feature parameter ...READ MORE

answered Jul 20, 2020 in Machine Learning by MD
• 95,040 points
1,491 views