Evalml: AutoMLSearch์—์„œ ๋ชฉ๋ก ๊ฐ’ ์ดˆ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2021๋…„ 03์›” 23์ผ  ยท  2์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: alteryx/evalml

์žฌํ˜„:

from evalml.demos import load_breast_cancer
from evalml.pipelines import BinaryClassificationPipeline
from evalml.automl import AutoMLSearch

class PipeLine(BinaryClassificationPipeline):
    component_graph = ["Drop Columns Transformer", "Random Forest Classifier"]

X , y = load_breast_cancer()

automl = AutoMLSearch(X, y, problem_type="binary", allowed_pipelines=[PipeLine],
                      pipeline_parameters={"Drop Columns Transformer": {"columns": ["mean texture"]}})
automl.search()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~/sources/evalml/evalml/pipelines/component_graph.py in instantiate(self, parameters)
     77             try:
---> 78                 new_component = component_class(**component_parameters, random_seed=self.random_seed)
     79             except (ValueError, TypeError) as e:

~/sources/evalml/evalml/pipelines/components/transformers/column_selectors.py in __init__(self, columns, random_seed, **kwargs)
     15         if columns and not isinstance(columns, list):
---> 16             raise ValueError(f"Parameter columns must be a list. Received {type(columns)}.")
     17 

ValueError: Parameter columns must be a list. Received <class 'str'>.

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
<ipython-input-21-b4819258a317> in <module>
     10 automl = AutoMLSearch(X, y, problem_type="binary", allowed_pipelines=[PipeLine],
     11                       pipeline_parameters={"Drop Columns Transformer": {"columns": ["mean texture"]}})
---> 12 automl.search()

~/sources/evalml/evalml/automl/automl_search.py in search(self, show_iteration_plot)
    490         logger.info("Allowed model families: %s\n" % ", ".join([model.value for model in self.allowed_model_families]))
    491         self.search_iteration_plot = None
--> 492         if self.plot:
    493             self.search_iteration_plot = self.plot.search_iteration_plot(interactive_plot=show_iteration_plot)
    494 

~/sources/evalml/evalml/automl/automl_algorithm/iterative_algorithm.py in next_batch(self)
     63         next_batch = []
     64         if self._batch_number == 0:
---> 65             next_batch = [pipeline_class(parameters=self._transform_parameters(pipeline_class, {}), random_seed=self.random_seed)
     66                           for pipeline_class in self.allowed_pipelines]
     67 

~/sources/evalml/evalml/automl/automl_algorithm/iterative_algorithm.py in <listcomp>(.0)
     63         next_batch = []
     64         if self._batch_number == 0:
---> 65             next_batch = [pipeline_class(parameters=self._transform_parameters(pipeline_class, {}), random_seed=self.random_seed)
     66                           for pipeline_class in self.allowed_pipelines]
     67 

~/sources/evalml/evalml/pipelines/classification_pipeline.py in __init__(self, parameters, random_seed)
     23         """
     24         self._encoder = LabelEncoder()
---> 25         super().__init__(parameters, random_seed=random_seed)
     26 
     27     def fit(self, X, y):

~/sources/evalml/evalml/pipelines/pipeline_base.py in __init__(self, parameters, random_seed)
     77         else:
     78             self._component_graph = ComponentGraph(component_dict=self.component_graph, random_seed=self.random_seed)
---> 79         self._component_graph.instantiate(parameters)
     80 
     81         self.input_feature_names = {}

~/sources/evalml/evalml/pipelines/component_graph.py in instantiate(self, parameters)
     80                 self._is_instantiated = False
     81                 err = "Error received when instantiating component {} with the following arguments {}".format(component_name, component_parameters)
---> 82                 raise ValueError(err) from e
     83 
     84             component_instances[component_name] = new_component

ValueError: Error received when instantiating component Drop Columns Transformer with the following arguments {'columns': 'mean texture'}

IterativeAlgorithm ๋Š” ์˜๋„ํ•œ ๋™์ž‘์ด ์•„๋‹Œ columns ๋ชฉ๋ก์˜ ์ฒซ ๋ฒˆ์งธ ์š”์†Œ๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

@dsherry @chukarsten

#1862์—์„œ๋Š” ์ธ๋ฑ์Šค ์—ด์ด ์žˆ์„ ๋•Œ Drop Columns Transformer ๋ฅผ _get_preprocessing_components ์ถ”๊ฐ€ํ•œ ๋‹ค์Œ ํ•ด๋‹น ์—ด์„ self. pipeline_parameters ์—๋„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ด ๋ฌธ์ œ๊ฐ€ ์ด๋ฅผ ์ฐจ๋‹จํ•  ๊ณ„ํš์ž…๋‹ˆ๋‹ค.

๋ชจ๋“  2 ๋Œ“๊ธ€

์ด ๋ฌธ์ œ๋Š” IterativeAlgorithm ๊ฐ€ _transform_parameters ํ˜ธ์ถœํ•˜๊ณ  ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ์••์ถ•์„ ํ’€๋ ค๊ณ  ํ•  ๋•Œ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์ด ์ฝ”๋“œ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ pipeline_parameters ๋ฅผ ์ „๋‹ฌํ•˜์—ฌ ํ•˜์ดํผํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ํŠน์ • ํ•˜์œ„ ์ง‘ํ•ฉ์œผ๋กœ ๊ณ ์ •ํ•˜๊ฑฐ๋‚˜ ์„ค์ •ํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด:

    params = {'Imputer': {'numeric_impute_strategy': ['median', 'most_frequent']},
              'Decision Tree Regressor': {'max_depth': [17, 18, 19], 'max_features': Categorical(['auto'])},
              'Elastic Net Regressor': {"alpha": Real(0, 0.5), "l1_ratio": (0.01, 0.02, 0.03)}}
    automl = AutoMLSearch(X_train=X, y_train=y, problem_type='regression', pipeline_parameters=params, n_jobs=1)
    automl.search()

_transform_parameters ์˜ ์ฒซ ๋ฒˆ์งธ ๋ฐฐ์น˜์—์„œ max_depth ๋˜๋Š” numeric_impute_strategy ์™€ ๊ฐ™์€ ๋ชฉ๋ก ์ž…๋ ฅ์„ ์ฒ˜๋ฆฌํ•˜๋ ค๋ฉด ๋ชฉ๋ก์˜ ์ฒซ ๋ฒˆ์งธ ์š”์†Œ๋ฅผ ์„ ํƒํ•˜๊ฑฐ๋‚˜ ์ƒ˜ํ”Œ๋งํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ํ•œ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์€ ์ด ์ค„ ์„ ์ œ๊ฑฐํ•˜๊ณ  ๋ชฉ๋ก์ด ํ—ˆ์šฉ๋˜์ง€ ์•Š๋„๋ก ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

@dsherry @freddyaboulton @bchen1116 @chukarsten FYI :)

@dsherry @chukarsten

#1862์—์„œ๋Š” ์ธ๋ฑ์Šค ์—ด์ด ์žˆ์„ ๋•Œ Drop Columns Transformer ๋ฅผ _get_preprocessing_components ์ถ”๊ฐ€ํ•œ ๋‹ค์Œ ํ•ด๋‹น ์—ด์„ self. pipeline_parameters ์—๋„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ด ๋ฌธ์ œ๊ฐ€ ์ด๋ฅผ ์ฐจ๋‹จํ•  ๊ณ„ํš์ž…๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰