Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33 lines (26 sloc)
954 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Adds together 3 or more numeric features""" | |
from h2oaicore.transformer_utils import CustomTransformer | |
import datatable as dt | |
import numpy as np | |
class SumTransformer(CustomTransformer): | |
_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.sum([dt.f[x] for x in range(X.ncols)])] |