1
1
# -*- encoding: utf-8 -*-
2
- from typing import Any , Dict , List , Optional
2
+ from typing import Any , Dict , List , Optional , Union
3
3
4
4
from ConfigSpace .configuration_space import ConfigurationSpace
5
5
6
- from sklearn . pipeline import Pipeline
6
+ import numpy as np
7
7
8
8
from autosklearn .constants import (
9
9
BINARY_CLASSIFICATION ,
16
16
from autosklearn .pipeline .regression import SimpleRegressionPipeline
17
17
18
18
19
- __all__ = [
20
- 'get_configuration_space' ,
21
- 'get_class' ,
22
- ]
19
+ __all__ = ['get_configuration_space' ]
23
20
24
21
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
29
29
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
+ """
30
49
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 )
32
51
else :
33
- return _get_classification_configuration_space (info , include , exclude )
52
+ return _get_classification_configuration_space (info , include , exclude , random_state )
53
+
34
54
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
35
62
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
+ """
40
82
task_type = info ['task' ]
41
83
sparse = False
42
84
multioutput = False
@@ -54,15 +96,39 @@ def _get_regression_configuration_space(info: Dict[str, Any],
54
96
configuration_space = SimpleRegressionPipeline (
55
97
dataset_properties = dataset_properties ,
56
98
include = include ,
57
- exclude = exclude
99
+ exclude = exclude ,
100
+ random_state = random_state
58
101
).get_hyperparameter_search_space ()
59
102
return configuration_space
60
103
61
104
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
+ """
66
132
task_type = info ['task' ]
67
133
68
134
multilabel = False
@@ -87,12 +153,7 @@ def _get_classification_configuration_space(info: Dict[str, Any],
87
153
88
154
return SimpleClassificationPipeline (
89
155
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