mojolearn.Binarizer#

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

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)

See also

User guide: Preprocessing

Choosing an estimator

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])

fit_transform(X, y=None, **fit_params)#

Fit to X, then transform X.

Returns:

array – The transformed data.

get_params(deep=True)#

Return the constructor parameters as a dict.

Parameters:

deep (bool, default True) – Accepted for scikit-learn compatibility.

Returns:

dict – Parameter names mapped to their values.

set_params(**params)#

Set constructor parameters.

An unknown parameter name raises ValueError.

Returns:

self