module feature_selection.river.river_feature_selector
River Feature Selection Model Wrapper.
This module contains a wrapper class for river feature selection models.
Copyright (C) 2022 Johannes Haug.
class RiverFeatureSelector
Wrapper for river feature selection models.
method RiverFeatureSelector.__init__
__init__(
model: river.base.transformer.Transformer,
feature_names: List[str],
n_total_features: int,
reset_after_drift: bool = False,
baseline: str = 'constant',
ref_sample: Union[float, numpy._array_like._SupportsArray[numpy.dtype], numpy._nested_sequence._NestedSequence[numpy._array_like._SupportsArray[numpy.dtype]], bool, int, complex, str, bytes, numpy._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]] = 0
)
Inits the wrapper.
Args:
model
: The river feature selector object (one of SelectKBest, PoissonInclusion or VarianceThreshold).feature_names
: A list of all feature names.n_total_features
: The total number of features.reset_after_drift
: A boolean indicating if the change detector will be reset after a drift was detected.baseline
: A string identifier of the baseline method. The baseline is the value that we substitute non-selected features with. This is necessary, because most online learning models are not able to handle arbitrary patterns of missing data.ref_sample
: A sample used to compute the baseline. If the constant baseline is used, one needs to provide a single float value.
method RiverFeatureSelector.reset
reset()
Resets the feature selector.
method RiverFeatureSelector.select_features
select_features(
X: Union[numpy._array_like._SupportsArray[numpy.dtype], numpy._nested_sequence._NestedSequence[numpy._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]],
rng: numpy.random._generator.Generator
) → Union[numpy._array_like._SupportsArray[numpy.dtype], numpy._nested_sequence._NestedSequence[numpy._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]
Selects features with highest absolute weights.
This overrides the corresponding parent class function.
Args:
X
: Array/matrix of observations.rng
: A numpy random number generator object.
Returns:
ArrayLike
: The observation array/matrix where all non-selected features have been replaced by the baseline value.
method RiverFeatureSelector.weight_features
weight_features(
X: Union[numpy._array_like._SupportsArray[numpy.dtype], numpy._nested_sequence._NestedSequence[numpy._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]],
y: Union[numpy._array_like._SupportsArray[numpy.dtype], numpy._nested_sequence._NestedSequence[numpy._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]
)
Updates feature weights.
Args:
X
: Array/matrix of observations.y
: Array of corresponding labels.
This file was automatically generated via lazydocs.