mojolearn.VarianceThreshold#
- class mojolearn.VarianceThreshold(threshold=0.0)[source]#
Bases:
_SelectorMixinFeature selector that removes low-variance features.
Follows scikit-learn’s
VarianceThreshold. Fit computes each column’s population variance over its non-NaN values and keeps the columns whose variance is greater thanthreshold. With the default threshold of 0, a constant column has variance exactly 0 and is removed. Fit raisesValueErrorwhen no column passes.- Parameters:
threshold (float, default 0.0) – Columns with variance at or below this are removed.
- Variables:
Examples
>>> import numpy as np, mojolearn >>> X = np.array([[0, 2, 0, 3], [0, 1, 4, 3], [0, 1, 1, 3]], dtype=np.float32) >>> mojolearn.VarianceThreshold().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.
get_support([indices])Return the selected features.
set_params(**params)Set constructor parameters.
transform(X)Keep only the selected columns of
X.