biomedical_data_generator.features.informative
Generation of standalone informative features and class separation.
This module builds numeric class labels from DatasetConfig.class_configs,
samples base values for standalone informative features according to per-class
distributions, and applies class-wise mean shifts controlled by the
per-group class_sep on DatasetConfig.standalone_informative_groups.
- Scope:
Only standalone informative features are produced here (i.e. informative features that are not cluster anchors). Correlated clusters, including their anchors and the attenuated proxy shifts, are handled in
correlated.py. Independent noise features are sampled directly ingenerator.pyviautils.sampling.sample_distribution.
The standalone-informative block is partitioned into contiguous groups, each
carrying its own class_sep. The class-wise offsets are derived per group
from class_sep by _class_offsets_from_sep and applied as pure mean
shifts, so the per-class distribution shape is preserved.
Functions
|
Generate all standalone informative features (no anchors, no clusters). |
Resolve the column layout and centered per-class offsets of each group. |
- biomedical_data_generator.features.informative.generate_informative_features(cfg, rng)[source]
Generate all standalone informative features (no anchors, no clusters).
The function performs:
Build numeric labels
yfromcfg.class_configs.Allocate a matrix
x_informativeof shape(n_samples, n_standalone_informative).Base draw over the entire block: for each class in declaration order, sample a contiguous
(n_class_samples, n_standalone_informative)block spanning all columns.Per-group offsets: partition the columns into the contiguous groups of
cfg.standalone_informative_groups(declaration order, laid out at the front of the matrix), and for each group add the class-wise offsets derived from that group’sclass_septo its column range.
- Draw/offset order (load-bearing for reproducibility):
The base draw is performed class-by-class over the full block width, identical to the pre-groups implementation. Because offsets are pure mean shifts that consume no randomness, the RNG draw count and order are a pure function of
(config, seed)and are independent of how the block is partitioned into groups. For a single group spanning the whole block this reproduces the previous behavior byte-for-byte: the only difference from the old code is that the constant offset is added after the draw rather than inside the per-class loop, which cannot change RNG consumption.
- Parameters:
cfg (DatasetConfig) – DatasetConfig with validated fields and derived quantities.
rng (Generator) – NumPy random Generator.
- Returns:
- x_informative: Array of shape (n_samples, n_standalone_informative) with
standalone informative features.
y: Array of shape (n_samples,) with class labels in {0, …, K-1}.
- Return type:
- biomedical_data_generator.features.informative.resolve_standalone_groups(cfg)[source]
Resolve the column layout and centered per-class offsets of each group.
Mirrors exactly the contiguous, declaration-order layout and the per-class mean shifts applied by
generate_informative_features(): groupgoccupies the nextn_featurescolumns at the front of the matrix, and its offset vector (lengthn_classes) is derived from the group’sclass_sepby the same_resolve_group_sep/_class_offsets_from_seppath. Because every value is read from the resolved config, the result is reproducible without the feature matrix.