PreciseCorrelationFilter

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 PreciseCorrelationFilter(corr_threshold: float = 0.7, p_threshold: float = 0.05)[source]

Bases: object

Prior 2024 Spearman screen: signed r, p-value, keep the later column.

correlation_filter uses |r| and keeps the first column. This method copies filtering() in precise-habitats so a habitat spec can lock the same column rule as that paper’s published code.

Parameters:
  • corr_threshold – Signed Spearman cut-off; drop when r is greater.

  • p_threshold – Spearman p-value cut-off; drop only when p is smaller.

__init__(corr_threshold: float = 0.7, p_threshold: float = 0.05) → None[source]
property spec: Spec

Return the algorithm specification.

fit(block: DataFrame) → Dict[str, Any][source]

Learn the surviving column subset on the training (baseline) matrix.

Parameters:

block – Unit-by-feature matrix to screen.

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.