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: object

Drop 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 <= threshold are dropped; 0.0 removes only constant columns.

__init__(variance_threshold: float = 0.0) → None[source]
property spec: Spec

Return the algorithm specification.

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 block are skipped rather than raising, matching v0.1.