forked from automl/Auto-PyTorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoCoalescer.py
More file actions
51 lines (41 loc) · 1.49 KB
/
Copy pathNoCoalescer.py
File metadata and controls
51 lines (41 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from typing import Any, Dict, Optional, Union
import numpy as np
from autoPyTorch.pipeline.components.preprocessing.tabular_preprocessing.coalescer.base_coalescer import BaseCoalescer
class NoCoalescer(BaseCoalescer):
"""
Don't perform NoCoalescer on categorical features
"""
def __init__(self,
random_state: Optional[Union[np.random.RandomState, int]] = None
):
super().__init__()
self.random_state = random_state
def fit(self, X: Dict[str, Any], y: Any = None) -> BaseCoalescer:
"""
The fit function calls the fit function of the underlying model
and returns the transformed array.
Args:
X (np.ndarray): input features
y (Optional[np.ndarray]): input labels
Returns:
instance of self
"""
self.check_requirements(X, y)
return self
def transform(self, X: Dict[str, Any]) -> Dict[str, Any]:
"""
Adds the self into the 'X' dictionary and returns it.
Args:
X (Dict[str, Any]): 'X' dictionary
Returns:
(Dict[str, Any]): the updated 'X' dictionary
"""
X.update({'coalescer': self.preprocessor})
return X
@staticmethod
def get_properties(dataset_properties: Optional[Dict[str, Any]] = None) -> Dict[str, Union[str, bool]]:
return {
'shortname': 'NoCoalescer',
'name': 'No Coalescer',
'handles_sparse': True
}