src.utils.preprocess

Module Contents

src.utils.preprocess.downcast(s, try_numeric=True, category=False)[source]

Downcast a series to the lowest possible memory type.

Parameters
spd.Series

Series to downcast.

try_numeric: bool

If True it will try to read strings as numeric values.

category: bool

If True (string) objects will be cast as a category.

Returns
Downcasted series.
src.utils.preprocess.map_labels(series, kind='categorical', labels=None, backwards=False, **arg)[source]

Map a Series values by the labels given.

Parameters
series: pd.Series

Series to map on.

kind: str

Indicator for kind of preprocess in series. With kind of {“categorical”, “ordinal”} the mapping is applied, otherwise not.

labels: dict

Defines with the mapping {key_0: value_0, etc.}.

arg:

Additional arguments.

Returns
pd.Series

Series with mapped values.

class src.utils.preprocess.MinMaxScaler(upper=1, lower=- 1)[source]

MinMax Scaler like in sklearn, prevents total library import/dependency.

Initialize scaler with upper and lower boundary.

Parameters
upperfloat

upper boundary to scale to

lowerfloat

lower boundary to scale to

fit(self, X, y=None)[source]

Get fit parameters.

Parameters
Xnp.array

preprocess to fit on

yNone

solely for consistency

Returns
self

instance with self.min, self.max defined.

transform(self, X)[source]

Scales preprocess according to fitted parameters.

Parameters
Xnp.array

preprocess to scale

Returns
np.array

scaled preprocess

fit_transform(self, X, y=None)[source]

Execute consecutively self.fit and self.transform.

Parameters
Xnp.array

preprocess to scale

yNone

solely for consistency

Returns
np.array

scaled preprocess

inverse_transform(self, X, y=None)[source]

Scale back to original domain.

Parameters
Xnp.array

preprocess to scale

yNone

solely for consistency

Returns
np.array

scaled preprocess