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 25, 2020 in Machine Learning by anonymous
• 120 points

recategorized Dec 28, 2020 by MD 108 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,180 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,180 points
1,808 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 1,741 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,180 points
522 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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,047 views
0 votes
0 answers
+1 vote
1 answer
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,180 points
2,817 views