value error found with inconsistent samples

0 votes

x_forecast = x[-forecast_out:]

x = x[:-forecast_out]

y = np.array(df['prediction'])

y = y[:-forecast_out]

x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state = 0)

clf = LinearRegressio()

clf.fit(train_x, train_y)

s = clf.score(test_x, test_y)

print('score', s)

error:

ValueError                                Traceback (most recent call last)
<ipython-input-80-7476b5a54000> in <module>()
----> 1 x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state = 0)
      2 
      3 clf = LinearRegressio()
      4 clf.fit(train_x, train_y)
      5 


2 frames


/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
    210     if len(uniques) > 1:
    211         raise ValueError("Found input variables with inconsistent numbers of"
--> 212                          " samples: %r" % [int(l) for l in lengths])
    213 
    214 
ValueError: Found input variables with inconsistent numbers of samples: [1417, 1477]
Dec 26, 2020 in Machine Learning by anonymous
• 120 points

recategorized Dec 28, 2020 by MD 1,421 views

1 answer to this question.

0 votes

Hi,

As you can see that you have an inconsistent number of samples in x and y. Before you create your model, you need to check the shape of the x and y variables. These two variables should have the same number of rows and y should be two dimensional.

answered Dec 28, 2020 by MD
• 95,460 points

Related Questions In Machine Learning

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,460 points
5,144 views
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 5,306 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,460 points
4,278 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+1 vote
2 answers

ValueError: Found input variables with inconsistent numbers of samples: [1, 1000]

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

answered Apr 14, 2020 in Machine Learning by MD
• 95,460 points

edited Aug 11, 2021 by Soumya 57,907 views
0 votes
1 answer

Found input variables with inconsistent numbers of samples:

Hi@sagar, You have converted your Dataframe into an ...READ MORE

answered Jul 13, 2020 in Machine Learning by MD
• 95,460 points
5,300 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP