WebDec 14, 2024 · 1 You don't need to reshape your predictors, doing that will flatten your matrix, so instead of: X = maindf [ ['Graduate Degree','Asian American Population']].values.reshape (-1,1) Do: X = maindf [ ['Graduate Degree','Asian American Population']] Below is running your code with an example dataset: Webdef check_consistent_length(*arrays): """Check that all arrays have consistent first dimensions. Checks whether all objects in arrays have the same shape or length. …
Found input variables with inconsistent numbers of samples: [164, 41]
WebFeb 2, 2024 · X_train,X_test,y_test,y_train=train_test_split (X,y,test_size=0.2) The mapping of values happens in this order based on train_test_split's return: X_train,X_test,y_train,y_test ie. y_train followed by y_test, hence the shape mismatch. Just change this and it'll work fine. Share Improve this answer Follow answered Feb 2, 2024 … WebChecks X and y for consistent length, enforces X to be 2D and y 1D. By default, X is checked to be non-empty and containing only finite values. Standard input checks are … mbe 460 egr cooler
How to Fix: Length of values does not match length of index
WebMay 18, 2024 · There's something weird about the dimensions of X_train and y_train. They automatically have the same number of rows after train_test_split, but for some reason you do reshape (-1,1) on X_train. This changes the number of rows for X_train, so of course it doesn't have the same number of rows as y_train, hence the error. WebFeb 23, 2024 · 1 Answer Sorted by: 0 Change line: y_pred = classifier.predict (x_train) to: y_pred = classifier.predict (x_test) and you're fine to go. Share Improve this answer Follow answered Feb 23, 2024 at 12:29 Sergey Bushmanov 22.2k 6 49 65 Add a … WebJun 14, 2024 · x_test = scaler_x.transform (x_test) rather than: x_train = scaler_x.transform (x_test). In short, the error basically says sizes of your x_train (which is actually x_test) and y_train doesn't match. Share Improve this answer Follow edited Jun 14, 2024 at 4:56 answered Jun 14, 2024 at 4:45 Y. Luo 5,552 1 18 25 Add a comment Your Answer mbe48b200bts spec sheet