33
44from autosklearn .automl import AutoMLClassifier , AutoMLRegressor
55from autosklearn .util .backend import create
6+ from sklearn .utils .multiclass import type_of_target
67
78
89class AutoSklearnEstimator (BaseEstimator ):
@@ -28,7 +29,9 @@ def __init__(self,
2829 shared_mode = False ,
2930 disable_evaluator_output = False ,
3031 get_smac_object_callback = None ,
31- smac_scenario_args = None ):
32+ smac_scenario_args = None ,
33+ logging_config = None ,
34+ ):
3235 """
3336 Parameters
3437 ----------
@@ -168,6 +171,11 @@ def __init__(self,
168171 This is an advanced feature. Use only if you are familiar with
169172 `SMAC <https://automl.github.io/SMAC3/stable/index.html>`_.
170173
174+ logging_config : dict, optional (None)
175+ dictionary object specifying the logger configuration. If None,
176+ the default logging.yaml file is used, which can be found in
177+ the directory ``util/logging.yaml`` relative to the installation.
178+
171179 Attributes
172180 ----------
173181
@@ -199,6 +207,7 @@ def __init__(self,
199207 self .disable_evaluator_output = disable_evaluator_output
200208 self .get_smac_object_callback = get_smac_object_callback
201209 self .smac_scenario_args = smac_scenario_args
210+ self .logging_config = logging_config
202211
203212 self ._automl = None
204213 super ().__init__ ()
@@ -238,7 +247,8 @@ def build_automl(self):
238247 shared_mode = self .shared_mode ,
239248 get_smac_object_callback = self .get_smac_object_callback ,
240249 disable_evaluator_output = self .disable_evaluator_output ,
241- smac_scenario_args = self .smac_scenario_args
250+ smac_scenario_args = self .smac_scenario_args ,
251+ logging_config = self .logging_config ,
242252 )
243253
244254 return automl
@@ -456,6 +466,18 @@ def fit(self, X, y,
456466 self
457467
458468 """
469+ # Before running anything else, first check that the
470+ # type of data is compatible with auto-sklearn. Legal target
471+ # types are: binary, multiclass, multilabel-indicator.
472+ target_type = type_of_target (y )
473+ if target_type in ['multiclass-multioutput' ,
474+ 'continuous' ,
475+ 'continuous-multioutput' ,
476+ 'unknown' ,
477+ ]:
478+ raise ValueError ("classification with data of type %s is"
479+ " not supported" % target_type )
480+
459481 super ().fit (
460482 X = X ,
461483 y = y ,
@@ -559,6 +581,18 @@ def fit(self, X, y,
559581 self
560582
561583 """
584+ # Before running anything else, first check that the
585+ # type of data is compatible with auto-sklearn. Legal target
586+ # types are: continuous, binary, multiclass.
587+ target_type = type_of_target (y )
588+ if target_type in ['multiclass-multioutput' ,
589+ 'multilabel-indicator' ,
590+ 'continuous-multioutput' ,
591+ 'unknown' ,
592+ ]:
593+ raise ValueError ("regression with data of type %s is not"
594+ " supported" % target_type )
595+
562596 # Fit is supposed to be idempotent!
563597 # But not if we use share_mode.
564598 super ().fit (
0 commit comments