1
1
"""Initalizes an transformer that selects specified columns in input data."""
2
+ import warnings
2
3
from abc import abstractmethod
3
4
from functools import wraps
5
+
4
6
import pandas as pd
5
7
import woodwork as ww
6
- import warnings
7
8
from sklearn .impute import SimpleImputer as SkImputer
8
-
9
- from woodwork .logical_types import Datetime
9
+ from woodwork .logical_types import (
10
+ BooleanNullable ,
11
+ Datetime ,
12
+ Double ,
13
+ )
10
14
from woodwork .statistics_utils import infer_frequency
11
15
12
- from checkmates .pipelines .transformers import Transformer
13
- from checkmates .pipelines .transformers import SimpleImputer
14
16
from checkmates .exceptions import ComponentNotYetFittedError
15
17
from checkmates .pipelines import ComponentBaseMeta
18
+ from checkmates .pipelines .transformers import SimpleImputer , Transformer
16
19
from checkmates .utils import infer_feature_types
17
20
from checkmates .utils .nullable_type_utils import (
18
- _get_new_logical_types_for_imputed_data ,
19
21
_determine_fractional_type ,
20
22
_determine_non_nullable_equivalent ,
23
+ _get_new_logical_types_for_imputed_data ,
21
24
)
22
25
23
26
24
-
25
27
class ColumnSelector (Transformer ):
26
28
"""Initalizes an transformer that selects specified columns in input data.
27
29
@@ -211,8 +213,10 @@ def transform(self, X, y=None):
211
213
modified_cols = self ._modify_columns (cols , X , y )
212
214
return infer_feature_types (modified_cols )
213
215
216
+
214
217
"""Transformer to drop rows specified by row indices."""
215
218
219
+
216
220
class DropRowsTransformer (Transformer ):
217
221
"""Transformer to drop rows specified by row indices.
218
222
@@ -300,8 +304,10 @@ def transform(self, X, y=None):
300
304
y_t = y_t .ww .drop (self .indices_to_drop )
301
305
return X_t , y_t
302
306
307
+
303
308
"""Component that imputes missing data according to a specified imputation strategy per column."""
304
309
310
+
305
311
class PerColumnImputer (Transformer ):
306
312
"""Imputes missing data according to a specified imputation strategy per column.
307
313
@@ -396,8 +402,10 @@ def transform(self, X, y=None):
396
402
X_t .ww .init (schema = original_schema .get_subset_schema (X_t .columns ))
397
403
return X_t
398
404
405
+
399
406
"""Component that imputes missing target data according to a specified imputation strategy."""
400
407
408
+
401
409
class TargetImputerMeta (ComponentBaseMeta ):
402
410
"""A version of the ComponentBaseMeta class which handles when input features is None."""
403
411
@@ -531,13 +539,9 @@ def fit_transform(self, X, y):
531
539
"""
532
540
return self .fit (X , y ).transform (X , y )
533
541
542
+
534
543
"""Component that imputes missing data according to a specified timeseries-specific imputation strategy."""
535
- import pandas as pd
536
- import woodwork as ww
537
- from woodwork .logical_types import (
538
- BooleanNullable ,
539
- Double ,
540
- )
544
+
541
545
542
546
class TimeSeriesImputer (Transformer ):
543
547
"""Imputes missing data according to a specified timeseries-specific imputation strategy.
@@ -776,8 +780,10 @@ def _handle_nullable_types(self, X=None, y=None):
776
780
777
781
return X , y
778
782
783
+
779
784
"""Transformer that regularizes a dataset with an uninferrable offset frequency for time series problems."""
780
785
786
+
781
787
class TimeSeriesRegularizer (Transformer ):
782
788
"""Transformer that regularizes an inconsistently spaced datetime column.
783
789
@@ -1086,4 +1092,4 @@ def transform(self, X, y=None):
1086
1092
1087
1093
cleaned_x .ww .init ()
1088
1094
1089
- return cleaned_x , cleaned_y
1095
+ return cleaned_x , cleaned_y
0 commit comments