-
Notifications
You must be signed in to change notification settings - Fork 93
/
sum.py
35 lines (27 loc) · 957 Bytes
/
sum.py
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
"""Adds together 3 or more numeric features"""
from h2oaicore.transformer_utils import CustomTransformer
import datatable as dt
import numpy as np
class SumTransformer(CustomTransformer):
_unsupervised = True
_regression = True
_binary = True
_multiclass = True
_numeric_output = True
_is_reproducible = True
_included_model_classes = None # List[str]
_excluded_model_classes = None # List[str]
_testing_can_skip_failure = False # ensure tested as if shouldn't fail
@staticmethod
def is_enabled():
return True
@staticmethod
def do_acceptance_test():
return True
@staticmethod
def get_default_properties():
return dict(col_type="numeric", min_cols=3, max_cols="all", relative_importance=1)
def fit_transform(self, X: dt.Frame, y: np.array = None):
return self.transform(X)
def transform(self, X: dt.Frame):
return X[:, dt.rowsum(dt.f[:])]