VarianceFilter
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- class VarianceFilter(variance_threshold: float = 0.0)[source]
Bases:
objectDrop feature columns whose variance is at or below a threshold.
A column that barely varies cannot separate one region from another, but still contributes a dimension to every distance computation downstream.
- Parameters:
variance_threshold – Columns with
var <= thresholdare dropped;0.0removes only constant columns.
- fit(block: DataFrame) Dict[str, Any][source]
Learn the surviving column subset.
- Parameters:
block – Unit-by-feature matrix to learn from.
- Returns:
State naming the columns to keep.
- transform(block: DataFrame, state: Mapping[str, Any]) DataFrame[source]
Restrict the matrix to the learned columns.
- Parameters:
block – Matrix to transform.
state – State from
fit().
- Returns:
The matrix with only the surviving columns. Columns absent from
blockare skipped rather than raising, matching v0.1.