leaspy.models.utils.initialization.model_initialization¶
Attributes¶
Functions¶
|
Initialize the model's group parameters given its name & the scores of all subjects. |
|
Fit a LME on univariate (per feature) time-series (feature vs. patients' ages with varying intercept & slope) |
|
Initialize the model's group parameters. |
Module Contents¶
- XI_STD = 0.5¶
- TAU_STD = 5.0¶
- NOISE_STD = 0.1¶
- SOURCES_STD = 1.0¶
- initialize_parameters(model, dataset, method='default')[source]¶
Initialize the model’s group parameters given its name & the scores of all subjects.
- Under-the-hood it calls an initialization function dedicated for the model:
initialize_linear()(including when univariate)initialize_logistic()(including when univariate)initialize_logistic_parallel()
It is automatically called during
Leaspy.fit().- Parameters:
- model
AbstractModel The model to initialize.
- dataset
Dataset Contains the individual scores.
- methodstr
- Must be one of:
'default': initialize at mean.'random': initialize with a gaussian realization with same mean and variance.
- model
- Returns:
- parametersdict [str,
torch.Tensor] Contains the initialized model’s group parameters.
- parametersdict [str,
- Raises:
LeaspyInputErrorIf no initialization method is known for model type / method
- Return type:
- get_lme_results(df, n_jobs=-1, *, with_random_slope_age=True, **lme_fit_kwargs)[source]¶
Fit a LME on univariate (per feature) time-series (feature vs. patients’ ages with varying intercept & slope)
- Parameters:
- df
pd.DataFrame Contains all the data (with nans)
- n_jobsint
Number of jobs in parallel when multiple features to init Not used for now, buggy
- with_random_slope_agebool (default True)
Has LME model a random slope per age (otherwise only a random intercept).
- **lme_fit_kwargs
Kwargs passed to ‘lme_fit’ (such as force_independent_random_effects, default True)
- df
- Returns:
- dict
{param: str -> param_values_for_ft: torch.Tensor(nb_fts, *shape_param)}
- Parameters:
df (DataFrame)
- lme_init(model, df, fact_std=1.0, **kwargs)[source]¶
Initialize the model’s group parameters.
- Parameters:
- model
AbstractModel The model to initialize (must be an univariate or multivariate linear or logistic manifold model).
- df
pd.DataFrame Contains the individual scores (with nans).
- fact_stdfloat
Multiplicative factor to apply on std-dev (tau, xi, noise) found naively with LME
- **kwargs
Additional kwargs passed to
get_lme_results()
- model
- Returns:
- parametersdict [str, torch.Tensor]
Contains the initialized model’s group parameters.
- Raises:
LeaspyInputErrorIf model is not supported for this initialization
- Parameters:
df (DataFrame)