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 thanthresholdbecome 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:
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)
Methods
fit(X[, y])fit_transform(X[, y])Fit to
X, then transformX.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 transformX.- 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