Binning

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 Binning(n_bins: int = 10, bin_strategy: str = 'uniform', across_features: bool = False)[source]

Bases: object

Discretise features into ordinal bin indices.

The characteristic cohort-level step for radiomics-heavy feature sets: replacing a continuous value with its bin index discards the fine variation that mostly reflects acquisition noise, while keeping the ordering that carries biology. Because bin edges come from the pooled cohort, the same index means the same thing across subjects.

Parameters:
  • n_bins – Number of bins.

  • bin_strategy – uniform, quantile or kmeans.

  • across_features – Learn one set of edges from the pooled values.

__init__(n_bins: int = 10, bin_strategy: str = 'uniform', across_features: bool = False) → None[source]
set_random_state(seed: int) → None[source]

Seed the stochastic kmeans bin strategy.

property spec: Spec

Return the algorithm specification.

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

Learn the bin edges.

Parameters:

block – Unit-by-feature matrix to learn from.

Returns:

State to pass to transform().

transform(block: DataFrame, state: Mapping[str, Any]) → DataFrame[source]

Map the matrix onto the learned bins.

Parameters:
  • block – Matrix to transform.

  • state – State from fit().

Returns:

The binned matrix.

Examples using habit.feature_preprocessing.Binning

Preprocessing voxel texture before clustering

Preprocessing voxel texture before clustering