Skip to content

GridSearchCV Error: Shape Mismatch Causes Pipeline Failure

A user encountered an error when using GridSearchCV to train a pipeline model, despite the model training successfully without GridSearchCV. The error message indicated a shape mismatch: “Shape of passed values is (12610, 54), indices imply (12610, 55).” This suggests that the data transformation within the pipeline results in a different number of features than expected. The pipeline involved several steps including feature engineering, where new features were created by combining existing ones, potentially leading to the discrepancy in feature counts. The user’s data set has 12,610 rows, and the pipeline was set up to handle various types of data transformations like imputation, scaling, and encoding. The error occurs during the GridSearchCV process, which is used to find the best parameters for a Random Forest Regressor, with parameters like the number of estimators, max depth, and minimum samples split being tested.

Source: stackoverflow.com

Related Links

Related Videos