11# -*- encoding: utf-8 -*-
2- from typing import Any , Dict , List , Optional
2+ from typing import Any , Dict , List , Optional , Union
33
44from ConfigSpace .configuration_space import ConfigurationSpace
55
6- from sklearn . pipeline import Pipeline
6+ import numpy as np
77
88from autosklearn .constants import (
99 BINARY_CLASSIFICATION ,
1616from autosklearn .pipeline .regression import SimpleRegressionPipeline
1717
1818
19- __all__ = [
20- 'get_configuration_space' ,
21- 'get_class' ,
22- ]
19+ __all__ = ['get_configuration_space' ]
2320
2421
25- def get_configuration_space (info : Dict [str , Any ],
26- include : Optional [Dict [str , List [str ]]] = None ,
27- exclude : Optional [Dict [str , List [str ]]] = None ,
28- ) -> ConfigurationSpace :
22+ def get_configuration_space (
23+ info : Dict [str , Any ],
24+ include : Optional [Dict [str , List [str ]]] = None ,
25+ exclude : Optional [Dict [str , List [str ]]] = None ,
26+ random_state : Optional [Union [int , np .random .RandomState ]] = None
27+ ) -> ConfigurationSpace :
28+ """Get the configuration of a pipeline given some dataset info
2929
30+ Parameters
31+ ----------
32+ info: Dict[str, Any]
33+ Information about the dataset
34+
35+ include: Optional[Dict[str, List[str]]] = None
36+ A dictionary of what components to include for each pipeline step
37+
38+ exclude: Optional[Dict[str, List[str]]] = None
39+ A dictionary of what components to exclude for each pipeline step
40+
41+ random_state: Optional[Union[int, np.random.Randomstate]] = None
42+ The random state to use for seeding the ConfigSpace
43+
44+ Returns
45+ -------
46+ ConfigurationSpace
47+ The configuration space for the pipeline
48+ """
3049 if info ['task' ] in REGRESSION_TASKS :
31- return _get_regression_configuration_space (info , include , exclude )
50+ return _get_regression_configuration_space (info , include , exclude , random_state )
3251 else :
33- return _get_classification_configuration_space (info , include , exclude )
52+ return _get_classification_configuration_space (info , include , exclude , random_state )
53+
3454
55+ def _get_regression_configuration_space (
56+ info : Dict [str , Any ],
57+ include : Optional [Dict [str , List [str ]]],
58+ exclude : Optional [Dict [str , List [str ]]],
59+ random_state : Optional [Union [int , np .random .RandomState ]] = None
60+ ) -> ConfigurationSpace :
61+ """Get the configuration of a regression pipeline given some dataset info
3562
36- def _get_regression_configuration_space (info : Dict [str , Any ],
37- include : Optional [Dict [str , List [str ]]],
38- exclude : Optional [Dict [str , List [str ]]]
39- ) -> ConfigurationSpace :
63+ Parameters
64+ ----------
65+ info: Dict[str, Any]
66+ Information about the dataset
67+
68+ include: Optional[Dict[str, List[str]]] = None
69+ A dictionary of what components to include for each pipeline step
70+
71+ exclude: Optional[Dict[str, List[str]]] = None
72+ A dictionary of what components to exclude for each pipeline step
73+
74+ random_state: Optional[Union[int, np.random.Randomstate]] = None
75+ The random state to use for seeding the ConfigSpace
76+
77+ Returns
78+ -------
79+ ConfigurationSpace
80+ The configuration space for the regression pipeline
81+ """
4082 task_type = info ['task' ]
4183 sparse = False
4284 multioutput = False
@@ -54,15 +96,39 @@ def _get_regression_configuration_space(info: Dict[str, Any],
5496 configuration_space = SimpleRegressionPipeline (
5597 dataset_properties = dataset_properties ,
5698 include = include ,
57- exclude = exclude
99+ exclude = exclude ,
100+ random_state = random_state
58101 ).get_hyperparameter_search_space ()
59102 return configuration_space
60103
61104
62- def _get_classification_configuration_space (info : Dict [str , Any ],
63- include : Optional [Dict [str , List [str ]]],
64- exclude : Optional [Dict [str , List [str ]]]
65- ) -> ConfigurationSpace :
105+ def _get_classification_configuration_space (
106+ info : Dict [str , Any ],
107+ include : Optional [Dict [str , List [str ]]],
108+ exclude : Optional [Dict [str , List [str ]]],
109+ random_state : Optional [Union [int , np .random .RandomState ]] = None
110+ ) -> ConfigurationSpace :
111+ """Get the configuration of a classification pipeline given some dataset info
112+
113+ Parameters
114+ ----------
115+ info: Dict[str, Any]
116+ Information about the dataset
117+
118+ include: Optional[Dict[str, List[str]]] = None
119+ A dictionary of what components to include for each pipeline step
120+
121+ exclude: Optional[Dict[str, List[str]]] = None
122+ A dictionary of what components to exclude for each pipeline step
123+
124+ random_state: Optional[Union[int, np.random.Randomstate]] = None
125+ The random state to use for seeding the ConfigSpace
126+
127+ Returns
128+ -------
129+ ConfigurationSpace
130+ The configuration space for the classification pipeline
131+ """
66132 task_type = info ['task' ]
67133
68134 multilabel = False
@@ -87,12 +153,7 @@ def _get_classification_configuration_space(info: Dict[str, Any],
87153
88154 return SimpleClassificationPipeline (
89155 dataset_properties = dataset_properties ,
90- include = include , exclude = exclude ).\
91- get_hyperparameter_search_space ()
92-
93-
94- def get_class (info : Dict [str , Any ]) -> Pipeline :
95- if info ['task' ] in REGRESSION_TASKS :
96- return SimpleRegressionPipeline
97- else :
98- return SimpleClassificationPipeline
156+ include = include ,
157+ exclude = exclude ,
158+ random_state = random_state
159+ ).get_hyperparameter_search_space ()
0 commit comments