torchcell.transforms.coo_regression_to_classification.BaseBinningStrategy
- class BaseBinningStrategy[source]
Bases:
ABCBase class for strategies that bin continuous values into classes.
- clamp_values(values: Tensor, bin_edges: Tensor) Tensor[source]
Clamp values to be within bin edge range.
- compute_ordinal_labels(values: Tensor, bin_edges: Tensor) Tensor[source]
Compute ordinal labels with clamping for out-of-bounds values.
Threshold
kis 1 when the clamped value is>=interior edgek + 1, the same left-closed convention as the one-hot path (biniis[edge_i, edge_{i+1}), astorch.bucketize(..., right=True) - 1andnp.digitize): the number of ones equals the one-hot bin index, so a value exactly on an interior edge belongs to the bin that edge opens under both.
- compute_soft_labels(values: Tensor, bin_edges: Tensor, strategy: str = 'equal_width', sigma_scale: float = 3) Tensor[source]
Compute soft labels with clamping for out-of-bounds values.
Each row is a Gaussian on the bin centers normalized to sum to one, computed as a softmax of the log-weights
-0.5 * (distance / sigma) ** 2. The softmax subtracts the row maximum before exponentiating, so a narrow sigma whose raw weights would all underflow to 0 still yields a distribution.