Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when training with optimize_final_model = True #417

Open
chjq201410695 opened this issue Oct 30, 2018 · 2 comments
Open

Error when training with optimize_final_model = True #417

chjq201410695 opened this issue Oct 30, 2018 · 2 comments

Comments

@chjq201410695
Copy link

My environment is ubantu 16.08.

here is my code:

column_descriptions = {
'booking': 'output',
('UN', 'TS', 'ICS', 'MS'): 'categorical'
}
ml_predictor = Predictor(type_of_estimator='regressor',
column_descriptions=column_descriptions)

ml_predictor.train(train, optimize_final_model=True, ml_for_analytics=False,
take_log_of_y=True, model_names=['LGBMRegressor', 'XGBRegressor', 'DeepLearningRegressor'],
cv=9, feature_learning=False,
prediction_intervals=True,compare_all_models=True)

ml_predictor.score(test, test.booking)


The error is:


ypeError Traceback (most recent call last)
in ()
9 take_log_of_y=True, model_names=['LGBMRegressor', 'XGBRegressor', 'DeepLearningRegressor'],
10 cv=9, feature_learning=False,
---> 11 prediction_intervals=True,compare_all_models=True)
12
13 ml_predictor.score(test, test.booking)

~/.conda/envs/ML_DNN/lib/python3.6/site-packages/auto_ml/predictor.py in train(failed resolving arguments)
668
669 # This is our main logic for how we train the final model
--> 670 self.trained_final_model = self.train_ml_estimator(self.model_names, self._scorer, X_df, y)
671
672 if self.ensemble_config is not None and len(self.ensemble_config) > 0:

~/.conda/envs/ML_DNN/lib/python3.6/site-packages/auto_ml/predictor.py in train_ml_estimator(self, estimator_names, scoring, X_df, y, feature_learning, prediction_interval)
1267 self.grid_search_params = grid_search_params
1268
-> 1269 gscv_results = self.fit_grid_search(X_df, y, grid_search_params, feature_learning=feature_learning)
1270
1271 all_gs_results.append(gscv_results)

~/.conda/envs/ML_DNN/lib/python3.6/site-packages/auto_ml/predictor.py in fit_grid_search(self, X_df, y, gs_params, feature_learning, refit)
1154 generations_number=generations_number,
1155 # Do not fit the best estimator on all the data- we will do that later, possibly after increasing epochs or n_estimators
-> 1156 refit=refit
1157
1158 )

TypeError: Can't instantiate abstract class EvolutionaryAlgorithmSearchCV with abstract methods _run_search

I found that the error appears when I set the optimize_final_model = True.


I have tried using pathos.multiprocessing.Pool instead of multiprocessing.Pool in "evolutionary_search/cv.py" mentioned by @kngo107 in issue #376
but it does not work yet.

any other advise?

@mohataher
Copy link

mohataher commented Oct 31, 2018

Can confirm, I'm receiving the same error with the following code:

ml_predictor = Predictor(type_of_estimator='regressor',  column_descriptions=column_descriptions)
ml_predictor.train(X_train, model_names=['DeepLearningRegressor'], optimize_final_model=True)
score = ml_predictor.score(X_test, X_test.y)

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-38-181ddefc36c8> in <module>
     14     ml_predictor = Predictor(type_of_estimator='regressor',  column_descriptions=column_descriptions)
     15     # ml_predictor.train(X_train, model_names=['DeepLearningRegressor'])
---> 16     ml_predictor.train(X_train, model_names=['DeepLearningRegressor'], optimize_final_model=True)
     17     score = ml_predictor.score(X_test, X_test.y)
     18     if (best_score<score):

c:\users\mtaher\appdata\local\programs\python\python36\lib\site-packages\auto_ml\predictor.py in train(***failed resolving arguments***)
    668 
    669         # This is our main logic for how we train the final model
--> 670         self.trained_final_model = self.train_ml_estimator(self.model_names, self._scorer, X_df, y)
    671 
    672         if self.ensemble_config is not None and len(self.ensemble_config) > 0:

c:\users\mtaher\appdata\local\programs\python\python36\lib\site-packages\auto_ml\predictor.py in train_ml_estimator(self, estimator_names, scoring, X_df, y, feature_learning, prediction_interval)
   1267                 self.grid_search_params = grid_search_params
   1268 
-> 1269                 gscv_results = self.fit_grid_search(X_df, y, grid_search_params, feature_learning=feature_learning)
   1270 
   1271                 all_gs_results.append(gscv_results)

c:\users\mtaher\appdata\local\programs\python\python36\lib\site-packages\auto_ml\predictor.py in fit_grid_search(self, X_df, y, gs_params, feature_learning, refit)
   1154                 generations_number=generations_number,
   1155                 # Do not fit the best estimator on all the data- we will do that later, possibly after increasing epochs or n_estimators
-> 1156                 refit=refit
   1157 
   1158             )

TypeError: Can't instantiate abstract class EvolutionaryAlgorithmSearchCV with abstract methods _run_search

mohataher pushed a commit to mohataher/auto_ml that referenced this issue Nov 1, 2018
@asvany
Copy link

asvany commented Nov 6, 2018

workaround:

  1. downgrade the scikit learn to 19.2 'pip install -U scikit-learn==0.19.2'
  2. remove the dummy parameter from the constructor:
    auto_ml/predictor.py:1149 " pre_dispatch='1.5*n_jobs', "

(((
comment from "class EvolutionaryAlgorithmSearchCV(BaseSearchCV):"

pre_dispatch : int, or string, optional
    Dummy parameter for compatibility with sklearn's GridSearch

)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants