Invalid parameter 'max_depth' for estimator GaussianProcessRegressor()

35 Views Asked by At

I am trying to develop an automated model which runs 5 algorithms, hyper tunes them and chooses the best based on mse ((Please note that this is to automate the estimation process such that whatever data the input can be modeled and predicted) but I am getting the following error:

ValueError: Invalid parameter 'max_depth' for estimator GaussianProcessRegressor(). Valid parameters are: ['alpha', 'copy_X_train', 'kernel', 'n_restarts_optimizer', 'n_targets', 'normalize_y', 'optimizer', 'random_state'].

I have tried taking out the Gaussian Process Regressor but I still get the same error. I also tried changing the tuning for GPR to not use Grid_Search but I still get the error. This is the code I used:

if best_estimator:
        # Hyperparameter tuning section for ANN
    if best_model_name == 'ANN':
        # Define hyperparameters and tuning grid for ANN
        param_grid = {
            'hidden_layer_sizes': [(50, 50), (100, 100)],
            'activation': ['relu', 'tanh'],
            'alpha': [0.0001, 0.001, 0.01],
        }
        grid_search = GridSearchCV(model, param_grid=param_grid, cv=3, scoring='neg_mean_squared_error')
        grid_search.fit(X_train_scaled, y_train)
        best_model_tuned = grid_search.best_estimator_
        print(f'Best ANN Model (Tuned): {best_model_tuned}')

    # Hyperparameter tuning section for XGBoost
    elif best_model_name == 'XGBoost':
        # Define hyperparameters and tuning grid for XGBoost
        param_grid = {
            'n_estimators': [50, 100, 200],
            'max_depth': [3, 5, 7]
        }
        grid_search = GridSearchCV(model, param_grid=param_grid, cv=3, scoring='neg_mean_squared_error')
        grid_search.fit(X_train_scaled, y_train)
        best_model_tuned = grid_search.best_estimator_
        print(f'Best XGBoost Model (Tuned): {best_model_tuned}')

    # Hyperparameter tuning section for Random Forest
    elif best_model_name == 'Random Forest':
        # Define hyperparameters and tuning grid for Random Forest
        param_grid = {
            'n_estimators': [50, 100, 200],
            'max_depth': [None, 10, 20]
        }
        grid_search = GridSearchCV(model, param_grid=param_grid, cv=3, scoring='neg_mean_squared_error')
        grid_search.fit(X_train_scaled, y_train)
        best_model_tuned = grid_search.best_estimator_
        print(f'Best Random Forest Model (Tuned): {best_model_tuned}')

    # Hyperparameter tuning section for SVM
    elif best_model_name == 'SVM':
        # Define hyperparameters and tuning grid for SVM
        param_grid = {
            'C': [0.1, 1, 10],
            'kernel': ['linear', 'rbf', 'poly']
        }
        grid_search = GridSearchCV(model, param_grid=param_grid, cv=3, scoring='neg_mean_squared_error')
        grid_search.fit(X_train_scaled, y_train)
        best_model_tuned = grid_search.best_estimator_
        print(f'Best SVM Model (Tuned): {best_model_tuned}')

    # Hyperparameter tuning section for Gaussian Process Regressor
    elif best_model_name == 'Gaussian Process':
        # Define hyperparameters and tuning grid for Gaussian Process Regressor
        param_grid = {
            #'kernel': [1.0 * RBF(1.0), 1.0 * RationalQuadratic(), 1.0 * ExpSineSquared(1.0, 5.0)],
        }
        grid_search = GridSearchCV(model, param_grid=param_grid, cv=3, scoring='neg_mean_squared_error')
        grid_search.fit(X_train_scaled, y_train)
        best_model_tuned = grid_search.best_estimator_
        print(f'Best Gaussian Process Regressor Model (Tuned): {best_model_tuned}')
0

There are 0 best solutions below