Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (18 sloc) 841 Bytes
"""Winsorizes (truncates) univariate outliers outside of two standard deviations from the mean."""
from h2oaicore.transformer_utils import CustomTransformer
import datatable as dt
import numpy as np
class MyTwoSigmaWinsorizer(CustomTransformer):
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):
self.mean = X.mean1() = X.sd1()
return self.transform(X)
def transform(self, X: dt.Frame):
X = dt.Frame(X)
if is not None and self.mean is not None:
X[self.mean - 2 * > dt.f[0], float] = self.mean - 2 *
X[self.mean + 2 * < dt.f[0], float] = self.mean + 2 *
return X
You can’t perform that action at this time.