mojolearn.Binarizer#

class mojolearn.Binarizer(*, threshold=0.0, copy=True)[source]#

Bases: _PrepBase

Set feature values to 0 or 1 by a threshold.

Follows scikit-learn’s Binarizer: values greater than threshold become 1, the others 0; NaN is kept. The transformer is stateless: fit only records the number of columns. Input and output are float32.

Parameters:
  • threshold (float, default 0.0) – Values above this become 1.

  • copy (bool, default True) – Accepted for scikit-learn compatibility; transform always returns a new array.

Variables:
  • n_features_in_ (int) – Number of columns seen in fit.

  • numeric_mode_ (str) – Numeric mode at fit time; transform runs in the same mode.

Examples

>>> import numpy as np, mojolearn
>>> X = np.array([[-1.0, 0.5], [2.0, 0.0]], dtype=np.float32)
>>> mojolearn.Binarizer(threshold=0.25).fit_transform(X)
__init__(*, threshold=0.0, copy=True)[source]#

Methods

fit(X[, y])

fit_transform(X[, y])

Fit to X, then transform X.

get_params([deep])

Return the constructor parameters as a dict.

set_params(**params)

Set constructor parameters.

transform(X[, copy])