gridsearchcv

Can I get F1 score each time from GridSearchCV?

Can I get F1 score each time from GridSearchCV? Question: I want to show F1 score from gridsearch each loop of change parameter. I use f1_micro in the GridSearchCV like this. params = { ‘max_depth’: [None, 2, 4, 6, 8, 10], ‘max_features’: [None, ‘sqrt’, ‘log2’, 0.2, 0.4, 0.6, 0.8], } clf = GridSearchCV( estimator=DecisionTreeClassifier(), param_grid=params, …

Total answers: 1

Can't get GridSearchCV working with Keras

Can't get GridSearchCV working with Keras Question: I’m trying to use GridSearchCV to optimise the hyperparameters in a custom model built with Keras. My code so far: https://pastebin.com/ujYJf67c#9suyZ8vM The model definition: def build_nn_model(n, hyperparameters, loss, metrics, opt): model = keras.Sequential([ keras.layers.Dense(hyperparameters[0], activation=hyperparameters[1], # number of outputs to next layer input_shape=[n]), # number of features keras.layers.Dense(hyperparameters[2], …

Total answers: 1

Dynamically calling and assigning a variable from a config python files

Dynamically calling and assigning a variable from a config python files Question: I have a list of parameters in a config file, if a specific model file is called in my script I want to dynamically assign the appropriate parameters to the variable name config file looks like this: tune_model_selection = [‘logreg_module’, ‘random_forest_module’] logreg_module_tune_parameter_grid = …

Total answers: 1

ValueError: Unknown label type: continuous. When implementing regression

ValueError: Unknown label type: continuous. When implementing regression Question: I am trying to predict the price of taxi fares using a neural network, I managed to run it for one optimizer and for a given number of epochs, but when implementing gridSearchCV() to try out different optimizers and different amounts of epochs it outputs an …

Total answers: 1

How do use a GridSearch to search the parameters of a model in a pipeline?

How do use a GridSearch to search the parameters of a model in a pipeline? Question: I need to use grid search to search the parameters of model in my_pipeline How can I do this? I don’t want to search te parameters of the pipeline instead I want to search the parameters of the model …

Total answers: 1

Error while doing SVR for multiple outputs

Error while doing SVR for multiple outputs Question: Trying to do SVR for multiple outputs. Started by hyper-parameter tuning which worked for me. Now I want to create the model using the optimum parameters but I am getting an error. How to fix this? from sklearn.svm import SVR from sklearn.model_selection import GridSearchCV from sklearn.multioutput import …

Total answers: 1

How do I add external features to my pipeline?

How do I add external features to my pipeline? Question: There is a similar question asked here on SO many years back but there was no answer. I have the same question. I would like to add in new column(s) of data, in my case 3 columns for dummy variables, to a sparse matrix (from …

Total answers: 1

AttributeError: 'GridSearchCV' object has no attribute 'best_params_'

AttributeError: 'GridSearchCV' object has no attribute 'best_params_' Question: Grid search is a way to find the best parameters for any model out of the combinations we specify. I have formed a grid search on my model in the below manner and wish to find best parameters identified using this gridsearch. from sklearn.model_selection import GridSearchCV # …

Total answers: 2

GridSearchCV & RandomizedSearchCV – do you refit the model after running

GridSearchCV & RandomizedSearchCV – do you refit the model after running Question: I have some test and train data, the test data does not have any dependant variables. I’m currently running a GridSearchCV or RandomizedSearchCV to find the best paramaters. Should I pass all of my “test” X & y values into a GridSearchCV or …

Total answers: 2

pipeline for RandomOversampler, RandomForestClassifier & GridSearchCV

pipeline for RandomOversampler, RandomForestClassifier & GridSearchCV Question: I am working on a binary text classification problem. As the classes are highly imbalanced, I am using sampling techniques like RandomOversampler(). Then for classification I would use RandomForestClassifier() whose parameters need to be tuned using GridSearchCV(). I am trying to create a pipeline to do these in …

Total answers: 2