16
16
17
17
18
18
class autoPyTorchChoice (object ):
19
- """Allows for the dynamically generation of components as pipeline steps.
19
+ """
20
+ Allows for the dynamically generation of components as pipeline steps.
20
21
21
22
Args:
22
- dataset_properties (Dict[str, Union[str, BaseDatasetPropertiesType]]): Describes the dataset
23
- to work on
24
- random_state (Optional[np.random.RandomState]): allows to produce reproducible
25
- results by setting a seed for randomized settings
23
+ dataset_properties (Dict[str, Union[str, BaseDatasetPropertiesType]]):
24
+ Describes the dataset to work on
25
+ random_state (Optional[np.random.RandomState]):
26
+ Allows to produce reproducible results by setting a
27
+ seed for randomized settings
26
28
27
29
Attributes:
28
- random_state (Optional[np.random.RandomState]): allows to produce reproducible
29
- results by setting a seed for randomized settings
30
- choice (autoPyTorchComponent): the choice of components for this stage
30
+ random_state (Optional[np.random.RandomState]):
31
+ Allows to produce reproducible results by setting a seed for
32
+ randomized settings
33
+ choice (autoPyTorchComponent):
34
+ the choice of components for this stage
31
35
"""
32
36
def __init__ (self ,
33
37
dataset_properties : Dict [str , BaseDatasetPropertiesType ],
@@ -67,11 +71,13 @@ def get_components(cls: 'autoPyTorchChoice') -> Dict[str, autoPyTorchComponent]:
67
71
for current step.
68
72
69
73
Args:
70
- cls (autoPyTorchChoice): The choice object from which to query the valid
74
+ cls (autoPyTorchChoice):
75
+ The choice object from which to query the valid
71
76
components
72
77
73
78
Returns:
74
- Dict[str, autoPyTorchComponent]: The available components via a mapping
79
+ Dict[str, autoPyTorchComponent]:
80
+ The available components via a mapping
75
81
from the module name to the component class
76
82
77
83
"""
@@ -88,10 +94,13 @@ def get_available_components(
88
94
user specification
89
95
90
96
Args:
91
- dataset_properties (Optional[Dict[str, BaseDatasetPropertiesType]]): Describes the dataset to work on
92
- include: Optional[Dict[str, Any]]: what components to include. It is an exhaustive
97
+ dataset_properties (Optional[Dict[str, BaseDatasetPropertiesType]]):
98
+ Describes the dataset to work on
99
+ include: Optional[Dict[str, Any]]:
100
+ what components to include. It is an exhaustive
93
101
list, and will exclusively use this components.
94
- exclude: Optional[Dict[str, Any]]: which components to skip
102
+ exclude: Optional[Dict[str, Any]]:
103
+ which components to skip. Can't be used together with include
95
104
96
105
Results:
97
106
Dict[str, autoPyTorchComponent]: A dictionary with valid components for this
@@ -137,10 +146,10 @@ def set_hyperparameters(self,
137
146
to an actual parameter of the autoPyTorch component.
138
147
139
148
Args:
140
- configuration (Configuration): which configuration to apply to
141
- the chosen component
142
- init_params (Optional[Dict[str, any]]): Optional arguments to
143
- initialize the chosen component
149
+ configuration (Configuration):
150
+ Which configuration to apply to the chosen component
151
+ init_params (Optional[Dict[str, any]]):
152
+ Optional arguments to initialize the chosen component
144
153
145
154
Returns:
146
155
self: returns an instance of self
@@ -177,11 +186,15 @@ def get_hyperparameter_search_space(
177
186
"""Returns the configuration space of the current chosen components
178
187
179
188
Args:
180
- dataset_properties (Optional[Dict[str, BaseDatasetPropertiesType]]): Describes the dataset to work on
181
- default: (Optional[str]) : Default component to use in hyperparameters
182
- include: Optional[Dict[str, Any]]: what components to include. It is an exhaustive
189
+ dataset_properties (Optional[Dict[str, BaseDatasetPropertiesType]]):
190
+ Describes the dataset to work on
191
+ default: (Optional[str]):
192
+ Default component to use in hyperparameters
193
+ include: Optional[Dict[str, Any]]:
194
+ what components to include. It is an exhaustive
183
195
list, and will exclusively use this components.
184
- exclude: Optional[Dict[str, Any]]: which components to skip
196
+ exclude: Optional[Dict[str, Any]]:
197
+ which components to skip
185
198
186
199
Returns:
187
200
ConfigurationSpace: the configuration space of the hyper-parameters of the
@@ -193,8 +206,10 @@ def fit(self, X: Dict[str, Any], y: Any) -> autoPyTorchComponent:
193
206
"""Handy method to check if a component is fitted
194
207
195
208
Args:
196
- X (X: Dict[str, Any]): Dependencies needed by current component to perform fit
197
- y (Any): not used. To comply with sklearn API
209
+ X (X: Dict[str, Any]):
210
+ Dependencies needed by current component to perform fit
211
+ y (Any):
212
+ not used. To comply with sklearn API
198
213
"""
199
214
# Allows to use check_is_fitted on the choice object
200
215
self .fitted_ = True
@@ -205,19 +220,23 @@ def predict(self, X: np.ndarray) -> np.ndarray:
205
220
"""Predicts the target given an input, by using the chosen component
206
221
207
222
Args:
208
- X (np.ndarray): input features from which to predict the target
223
+ X (np.ndarray):
224
+ input features from which to predict the target
209
225
210
226
Returns:
211
- np.ndarray: the predicted target
227
+ np.ndarray:
228
+ the target prediction
212
229
"""
213
230
assert self .choice is not None , "Cannot call predict without initializing the component"
214
231
return self .choice .predict (X )
215
232
216
233
def transform (self , X : Dict [str , Any ]) -> Dict [str , Any ]:
217
234
"""
218
235
Adds the current choice in the fit dictionary
236
+
219
237
Args:
220
- X (Dict[str, Any]): fit dictionary
238
+ X (Dict[str, Any]):
239
+ fit dictionary
221
240
222
241
Returns:
223
242
(Dict[str, Any])
@@ -233,7 +252,8 @@ def check_requirements(self, X: Dict[str, Any], y: Any = None) -> None:
233
252
are honored before fit.
234
253
235
254
Args:
236
- X (Dict[str, Any]): Dictionary with fitted parameters. It is a message passing
255
+ X (Dict[str, Any]):
256
+ Dictionary with fitted parameters. It is a message passing
237
257
mechanism, in which during a transform, a components adds relevant information
238
258
so that further stages can be properly fitted
239
259
"""
@@ -246,7 +266,8 @@ def _check_dataset_properties(self, dataset_properties: Dict[str, BaseDatasetPro
246
266
"""
247
267
A mechanism in code to ensure the correctness of the initialised dataset properties.
248
268
Args:
249
- dataset_properties:
269
+ dataset_properties (Dict[str, BaseDatasetPropertiesType]):
270
+ Describes the dataset to work on
250
271
251
272
"""
252
273
assert isinstance (dataset_properties , dict ), "dataset_properties must be a dictionary"
0 commit comments