-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathExampleLogTransformer.py
More file actions
34 lines (28 loc) · 971 Bytes
/
ExampleLogTransformer.py
File metadata and controls
34 lines (28 loc) · 971 Bytes
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
"""Apply log transform to any single numeric column."""
from h2oaicore.systemutils import segfault, loggerinfo, main_logger
from h2oaicore.transformer_utils import CustomTransformer
import datatable as dt
import numpy as np
import pandas as pd
import logging
class ExampleLogTransformer(CustomTransformer):
_regression = True
_binary = True
_multiclass = True
_numeric_output = True
_is_reproducible = True
_excluded_model_classes = ["tensorflow"]
@staticmethod
def do_acceptance_test():
return True
@staticmethod
def get_default_properties():
return dict(col_type="numeric", min_cols=1, max_cols=1, relative_importance=1)
def fit_transform(self, X: dt.Frame, y: np.array = None):
X_pandas = X.to_pandas()
X_p_log = np.log10(X_pandas)
return X_p_log
def transform(self, X: dt.Frame):
X_pandas = X.to_pandas()
X_p_log = np.log10(X_pandas)
return X_p_log