We Are Going To Discuss About ValueError: Found input variables with inconsistent numbers of samples: [1319, 245]. So lets Start this Python Article.
ValueError: Found input variables with inconsistent numbers of samples: [1319, 245]
- How to solve ValueError: Found input variables with inconsistent numbers of samples: [1319, 245]
Check the shape of both
X
andy
. It must have same number of rows.print(X.shape) print(y.shape) if X.shape[0] != y.shape[0]: print("X and y rows are mismatched, check dataset again")
Note:
The rows of both X and y should be same
You have useddataset
forX
whereasdataset1
fory
which should be the main error in your code.
See here:X = dataset[:,0:2] y = dataset1[:,2]
dataset and dataset1 are two different dataframes which might represent two different data. - ValueError: Found input variables with inconsistent numbers of samples: [1319, 245]
Check the shape of both
X
andy
. It must have same number of rows.print(X.shape) print(y.shape) if X.shape[0] != y.shape[0]: print("X and y rows are mismatched, check dataset again")
Note:
The rows of both X and y should be same
You have useddataset
forX
whereasdataset1
fory
which should be the main error in your code.
See here:X = dataset[:,0:2] y = dataset1[:,2]
dataset and dataset1 are two different dataframes which might represent two different data.
Solution 1
Check the shape of both X
and y
. It must have same number of rows.
print(X.shape)
print(y.shape)
if X.shape[0] != y.shape[0]:
print("X and y rows are mismatched, check dataset again")
Note:
- The rows of both X and y should be same
You have used dataset
for X
whereas dataset1
for y
which should be the main error in your code.
See here:
X = dataset[:,0:2]
y = dataset1[:,2]
dataset and dataset1 are two different dataframes which might represent two different data.
Original Author Prakash Dahal Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.