gfa.config#
Configuration classes for GFA model fitting and simulation.
Classes
Configuration for GFA model fitting. |
|
Experimental design parameters for GFA simulation. |
- class GFAFitConfig(
- *,
- x_dim_init: int = 1,
- fit_tol: float = 1e-08,
- max_iter: int = 1000000,
- prune_x: bool = True,
- prune_tol: float = 1e-07,
- save_x: bool = False,
- save_c_cov: bool = False,
- save_fit_progress: bool = True,
- random_seed: int | Sequence[int] | None = None,
- min_var_frac: float = 0.001,
Configuration for GFA model fitting.
All parameters have sensible defaults. Create with keyword arguments only. Instances are immutable (frozen).
- Parameters:
- x_dim_init
int Initial number of latent dimensions (before pruning). Must be >= 1.
- fit_tol
float Convergence tolerance for ELBO relative change. Must be > 0.
- max_iter
int Maximum EM iterations. Must be >= 1.
- prune_xbool
If True, remove latent dimensions that become inactive during fitting. Improves speed and memory for high initial
x_dim_init.- prune_tol
float Variance threshold for pruning. Latents with mean squared value below this are removed. Must be > 0.
- save_xbool
If True, save posterior latent estimates. Can be memory-intensive for large N.
- save_c_covbool
If True, save loading covariances. Can be memory-intensive for large y_dim and x_dim.
- save_fit_progressbool
If True, track ELBO and runtime per iteration.
- random_seed
int, sequence ofint, orNone RNG seed for reproducibility. Accepts a single non-negative integer, a non-empty sequence of non-negative integers (for structured seeding in parallel experiments), or None for random initialization.
- min_var_frac
float Private variance floor as fraction of data variance. Must be in (0, 1).
- x_dim_init
Examples
>>> config = GFAFitConfig(x_dim_init=10) >>> config.x_dim_init 10
>>> # Configs are immutable >>> config.x_dim_init = 20 # Raises FrozenInstanceError Traceback (most recent call last): ... dataclasses.FrozenInstanceError: cannot assign to field 'x_dim_init'
- class GFASimConfig(
- *,
- n_samples: int,
- y_dims: ndarray,
- x_dim: int,
- snr: float | ndarray = 1.0,
- random_seed: int | Sequence[int] | None = None,
Experimental design parameters for GFA simulation.
Defines the structure and reproducibility settings for generating synthetic GFA data. The probabilistic model specification (hyperprior) is provided separately to
simulate().All parameters except
random_seedare required. Instances are immutable (frozen).- Parameters:
- n_samples
int Number of data points to generate. Must be >= 1.
- y_dims
np.ndarray Dimensionalities of each observed group, shape
(n_groups,). Must be 1D array of positive integers.- x_dim
int Number of latent dimensions. Must be >= 1.
- snr
floatorndarray Signal-to-noise ratio. Either a scalar (broadcast to all groups) or per-group array of shape
(n_groups,). Must be > 0.- random_seed
int, sequence ofint, orNone RNG seed for reproducibility. Accepts a single non-negative integer, a non-empty sequence of non-negative integers (for structured seeding in parallel experiments), or None for random initialization. Required for reproducible recipe saves.
- n_samples
Examples
>>> config = GFASimConfig( ... n_samples=100, ... y_dims=np.array([10, 10, 10]), ... x_dim=5, ... snr=1.0, ... random_seed=42, ... ) >>> config.n_groups 3 >>> config.y_dim 30