auto_ml
auto_ml copied to clipboard
Error when training with optimize_final_model = True
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)
~/.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?
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
workaround:
- downgrade the scikit learn to 19.2 'pip install -U scikit-learn==0.19.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
)))