PlnLDA
Performs Linear Discriminant Analysis on the latent space of a PLN model. Main functionanlities are .predict_clusters(), .transform_new(), .transform(), .viz(), .viz_transformed().
See J. Chiquet, M. Mariadassou, S. Robin: The Poisson-Lognormal Model as a Versatile Framework for the Joint Analysis of Species Abundances for more information [pdf].
PlnLDA Documentation
- class pyPLNmodels.PlnLDA(endog, clusters, *, exog=None, offsets=None, compute_offsets_method='zero', add_const=False)[source]
Supervised Pln model. The classification is based on Linear Discriminant Analysis (LDA). This assumes the user have knowledge of clusters, and should be given in the initialization. See J. Chiquet, M. Mariadassou, S. Robin: “The Poisson-Lognormal Model as a Versatile Framework for the Joint Analysis of Species Abundances” for more information.
Examples
>>> from pyPLNmodels import PlnLDA, load_scrna, plot_confusion_matrix >>> data = load_scrna() >>> endog_train, endog_test = data["endog"][:100],data["endog"][100:] >>> labels_train, labels_test = data["labels"][:100], data["labels"][100:] >>> lda = PlnLDA(endog_train, clusters = labels_train).fit() >>> pred_test = lda.predict_clusters(endog_test) >>> plot_confusion_matrix(pred_test, labels_test)
See also
pyPLNmodels.Pln
,pyPLNmodels.PlnPCA
,pyPLNmodels.PlnMixture
,pyPLNmodels.PlnLDA.__init__()
,pyPLNmodels.PlnLDA.from_formula()
- Parameters:
endog (Tensor | ndarray | DataFrame)
clusters (Tensor | ndarray | DataFrame | Series)
exog (Tensor | ndarray | DataFrame | Series | None)
offsets (Tensor | ndarray | DataFrame | None)
compute_offsets_method ({'logsum', 'zero'})
add_const (bool)
- remove_zero_columns = False
- __init__(endog, clusters, *, exog=None, offsets=None, compute_offsets_method='zero', add_const=False)[source]
Initializes the model class.
- Parameters:
endog (Union[torch.Tensor, np.ndarray, pd.DataFrame]) – The count data.
exog (Union[torch.Tensor, np.ndarray, pd.DataFrame], optional(keyword-only)) – The covariate data. Defaults to None.
offsets (Union[torch.Tensor, np.ndarray, pd.DataFrame], optional(keyword-only)) – The offsets data. Defaults to None.
compute_offsets_method (str, optional(keyword-only)) –
- Method to compute offsets if not provided. Options are:
”zero” that will set the offsets to zero.
”logsum” that will take the logarithm of the sum (per line) of the counts.
Overridden (useless) if offsets is not None.
add_const (bool, optional(keyword-only)) – Whether to add a column of one in the exog. Defaults to True.
clusters (Tensor | ndarray | DataFrame | Series)
- Return type:
See also
pyPLNmodels.PlnLDA.from_formula()
,pyPLNmodels.Pln
,pyPLNmodels.PlnMixture
,pyPLNmodels.PlnPCA
Examples
- classmethod from_formula(formula, data, *, compute_offsets_method='zero')[source]
Create a model instance from a formula and data.
- Parameters:
formula (str) – The formula. Must have a pipe ‘|’ after the exogenous variables to specify the clusters.
data (dict) – The data dictionary. Each value can be either a torch.Tensor, np.ndarray, pd.DataFrame or pd.Series. The categorical exogenous data should be 1-dimensional.
compute_offsets_method (str, optional(keyword-only)) –
- Method to compute offsets if not provided. Options are:
”zero” that will set the offsets to zero.
”logsum” that will take the logarithm of the sum (per line) of the counts.
Overridden (useless) if data[“offsets”] is not None.
- Raises:
ValueError if the formula does not contains the pipe "|". –
- Return type:
PlnLDA object
- fit(*, maxiter=400, lr=0.01, tol=1e-06, verbose=False)[source]
Fit the model using variational inference. The lower the tol (tolerance), the more accurate the model.
- Parameters:
maxiter (int, optional) – The maximum number of iterations to be done. Defaults to 400.
lr (float, optional(keyword-only)) – The learning rate. Defaults to 0.01.
tol (float, optional(keyword-only)) – The tolerance for convergence. Defaults to 1e-6.
verbose (bool, optional(keyword-only)) – Whether to print training progress. Defaults to False.
- Raises:
ValueError – If maxiter is not an int.
- Return type:
PlnLDA object
Examples
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna() >>> lda = PlnLDA.from_formula("endog ~ 0| labels", data).fit() >>> print(lda)
- property clusters
The clusters of each sample given in initialization.
- property marginal_mean_clusters
Marginal mean given only by the clusters mean, that is, the mean of each cluster.
- property coef_clusters
Regression coefficients for the cluster variable.
- property dict_model_parameters
The parameters of the model.
- compute_elbo()[source]
Compute the elbo of the current parameters.
Examples
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna() >>> lda = PlnLDA.from_formula("endog ~ 0 | labels", data) >>> lda.fit() >>> elbo = lda.compute_elbo() >>> print(elbo)
- predict_clusters(endog, *, exog=None, offsets=None)[source]
Predict the clusters of the given endog and exog. The dimensions of endog, exog, and offsets should match the ones given in the model.
- Parameters:
endog (Union[torch.Tensor, np.ndarray, pd.DataFrame]) – The count data.
exog (Union[torch.Tensor, np.ndarray, pd.DataFrame], optional(keyword-only)) – The covariate data. Defaults to None.
offsets (Union[torch.Tensor, np.ndarray, pd.DataFrame], optional(keyword-only)) – The offsets data. Defaults to None.
- Raises:
ValueError – If the endog (or exog) has wrong shape compared to the previously fitted endog (or exog) variables.
- Returns:
list
- Return type:
The predicted clusters
Examples
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna() >>> endog = data["endog"] >>> clusters = data["labels_1hot"] >>> n_train, n_test = 100, 100 >>> endog_train = endog[:n_train] >>> endog_test = endog[n_train:] >>> clusters_train = clusters[:n_train] >>> clusters_test = clusters[n_train:] >>> lda = PlnLDA(endog_train, clusters = clusters_train) >>> lda.fit() >>> pred = lda.predict_clusters(endog_test) >>> print('pred', pred) >>> print('true', clusters_test)
- viz(*, ax=None, colors=None, show_cov=False, remove_exog_effect=True)[source]
Visualize the latent variables. One can remove the effect of exogenous variables with the remove_exog_effect boolean variable.
- Parameters:
ax (matplotlib.axes.Axes, optional) – The axes on which to plot, by default None.
colors (list, optional) – The labels to color the samples, of size n_samples.
show_cov (bool, optional) – Whether to show covariances, by default False.
remove_exog_effect (bool, optional) – Whether to remove or not the effect of exogenous variables. Default to False.
Examples
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna() >>> endog = data["endog"] >>> clusters = data["labels_1hot"] >>> n_train, n_test = 100, 100 >>> endog_train = endog[:n_train] >>> endog_test = endog[n_train:] >>> clusters_train = clusters[:n_train] >>> clusters_test = clusters[n_train:] >>> lda = PlnLDA(endog_train, clusters = clusters_train).fit() >>> lda.viz()
- plot_expected_vs_true(ax=None, colors=None)[source]
Plot the predicted value of the endog against the endog.
- Parameters:
ax (Optional[matplotlib.axes.Axes], optional) – The matplotlib axis to use. If None, the current axis is used, by default None.
colors (Optional[Any], optional) – The labels to color the samples, of size n_samples. By default None (no colors).
- Returns:
The matplotlib axis.
- Return type:
matplotlib.axes.Axes
See also
pyPLNmodels.Pln.pca_pairplot()
,pyPLNmodels.PlnPCA.pca_pairplot()
,pyPLNmodels.Pln.biplot()
,pyPLNmodels.PlnPCA.biplot()
Examples
- transform(remove_exog_effect=False)[source]
Transform the endog into the learned LDA space. The remove_exog_effect is not implemented for PlnLDA.
- Returns:
torch.Tensor
- Return type:
The transformed data
Examples
>>> import torch >>> from pyPLNmodels import PlnLDA, PlnLDASampler >>> ntrain, ntest = 300, 200 >>> nb_cov, n_cluster = 1,3 >>> sampler = PlnLDASampler( >>> n_samples=ntrain + ntest, nb_cov=nb_cov, n_cluster=n_cluster, add_const=False) >>> endog = sampler.sample() >>> known_exog = sampler.known_exog >>> clusters = sampler.clusters >>> endog_train, endog_test = endog[:ntrain], endog[ntrain:] >>> known_exog_train, known_exog_test = known_exog[:ntrain], known_exog[ntrain:] >>> clusters_train, clusters_test = clusters[:ntrain],clusters[ntrain:] >>> lda = PlnLDA(endog_train, >>> clusters = clusters_train, exog = known_exog_train, add_const = False).fit() >>> transformed_endog_train = lda.transform() >>> print('shape', transformed_endog_train.shape)
- transform_new(endog, *, exog=None, offsets=None)[source]
Transform the (unseen) endog data into the previously learned LDA space.
- Returns:
torch.Tensor
- Return type:
The transformed data
Examples
>>> import torch >>> from pyPLNmodels import PlnLDA, PlnLDASampler >>> ntrain, ntest = 300, 200 >>> nb_cov, n_cluster = 1,3 >>> sampler = PlnLDASampler( >>> n_samples=ntrain + ntest, nb_cov=nb_cov, n_cluster=n_cluster, add_const=False) >>> endog = sampler.sample() >>> known_exog = sampler.known_exog >>> clusters = sampler.clusters >>> endog_train, endog_test = endog[:ntrain], endog[ntrain:] >>> known_exog_train, known_exog_test = known_exog[:ntrain], known_exog[ntrain:] >>> clusters_train, clusters_test = clusters[:ntrain],clusters[ntrain:] >>> lda = PlnLDA(endog_train, >>> clusters = clusters_train, exog = known_exog_train, add_const = False).fit() >>> transformed_endog_test = lda.transform_new(endog_test, exog = known_exog_test) >>> print(transformed_endog_test.shape)
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna(n_samples = 500) >>> n_train = 250 >>> endog_train, endog_test = data["endog"][:n_train],data["endog"][n_train:] >>> labels_train, labels_test = data["labels"][:n_train], data["labels"][n_train:] >>> lda = PlnLDA(endog_train, clusters = labels_train).fit() >>> endog_test_transformed = lda.transform_new(endog_test)
- viz_transformed(transformed, colors=None, ax=None)[source]
Visualize the transformed data in the LDA space.
- Parameters:
transformed (torch.Tensor) – The transformed data.
colors (list, optional) – The labels to color the samples, of size transformed.shape[0].
ax (matplotlib.axes.Axes, optional) – The axes on which to plot, by default None.
Examples
>>> import torch >>> from pyPLNmodels import PlnLDA, PlnLDASampler >>> ntrain, ntest = 3000, 200 >>> nb_cov, n_cluster = 1,3 >>> sampler = PlnLDASampler( >>> n_samples=ntrain + ntest, nb_cov=nb_cov, n_cluster=n_cluster, add_const=False) >>> endog = sampler.sample() >>> known_exog = sampler.known_exog >>> clusters = sampler.clusters >>> endog_train, endog_test = endog[:ntrain], endog[ntrain:] >>> known_exog_train, known_exog_test = known_exog[:ntrain], known_exog[ntrain:] >>> clusters_train, clusters_test = clusters[:ntrain],clusters[ntrain:] >>> lda = PlnLDA(endog_train, >>> clusters = clusters_train, exog = known_exog_train, add_const = False).fit() >>> transformed_endog_test = lda.transform_new(endog_test, exog = known_exog_test) >>> lda.viz_transformed(transformed_endog_test)
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna(n_samples = 500) >>> n_train = 250 >>> endog_train, endog_test = data["endog"][:n_train],data["endog"][n_train:] >>> labels_train, labels_test = data["labels"][:n_train], data["labels"][n_train:] >>> lda = PlnLDA(endog_train, clusters = labels_train).fit() >>> endog_test_transformed = lda.transform_new(endog_test) >>> lda.viz_transformed(endog_test_transformed)
- property latent_positions_clusters
The latent positions with effects coming only from the clusters covariates (effects of ‘known’ covariates remove).
- property latent_variables
The (conditional) mean of the latent variables. This is the best approximation of latent variables. This variable is supposed to be more meaningful than the counts (endog).
See also
Examples
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna() >>> pln = PlnLDA.from_formula("endog ~ 0 | labels", data) >>> pln.fit() >>> print(pln.latent_variables.shape) >>> pln.viz() # Visualize the latent variables without exogenous effects.
- pca_pairplot(n_components=3, colors=None)[source]
Generates a scatter matrix plot based on Principal Component Analysis (PCA) on the latent variables.
- Parameters:
(int (n_components) – Defaults to 3. It Cannot be greater than 6.
optional) (The number of components to consider for plotting.) – Defaults to 3. It Cannot be greater than 6.
(np.ndarray) (colors) – sample in the endog property of the object. Defaults to None.
n_components (int)
colors (ndarray | None)
- Raises:
ValueError – If the number of components requested is greater: than the number of variables in the dataset.
Examples
>>> from pyPLNmodels import Pln, load_scrna >>> data = load_scrna() >>> pln = Pln.from_formula("endog ~ 1", data=data) >>> pln.fit() >>> pln.pca_pairplot(n_components=5) >>> pln.pca_pairplot(n_components=5, colors=data["labels"])
- plot_correlation_circle(column_names, column_index=None, title='')[source]
Visualizes variables using PCA and plots a correlation circle. If the endog has been given as a pd.DataFrame, the column_names have been stored and may be indicated with the column_names argument. Else, one should provide the indices of variables.
- Parameters:
column_names (List[str]) – A list of variable names to visualize. If column_index is None, the variables plotted are the ones in column_names. If column_index is not None, this only serves as a legend. Check the attribute column_names_endog.
column_index (Optional[List[int]], optional) – A list of indices corresponding to the variables that should be plotted. If None, the indices are determined based on column_names_endog given the column_names, by default None. If not None, should have the same length as column_names.
title (str) – An additional title for the plot.
- Raises:
ValueError – If column_index is None and column_names_endog is not set, that has been set if the model has been initialized with a pd.DataFrame as endog.
ValueError – If the length of column_index is different from the length of column_names.
Examples
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna() >>> lda = PlnLDA.from_formula("endog ~ 0|labels", data=data) >>> lda.fit() >>> lda.plot_correlation_circle(column_names=["MALAT1", "ACTB"]) >>> lda.plot_correlation_circle(column_names=["A", "B"], column_index=[0, 4])
- Raises:
ValueError – If the number of clusters is 2, as the latent variables will be of dimension and visualization is not possible.
- Parameters:
title (str)
- biplot(column_names, *, column_index=None, colors=None, title='')[source]
Visualizes variables using the correlation circle along with the pca transformed samples. If the endog has been given as a pd.DataFrame, the column_names have been stored and may be indicated with the column_names argument. Else, one should provide the indices of variables.
- Parameters:
column_names (List[str]) – A list of variable names to visualize. If column_index is None, the variables plotted are the ones in column_names. If column_index is not None, this only serves as a legend. Check the attribute column_names_endog.
column_index (Optional[List[int]], optional keyword-only) – A list of indices corresponding to the variables that should be plotted. If None, the indices are determined based on column_names_endog given the column_names, by default None. If not None, should have the same length as column_names.
title (str optional, keyword-only) – An additional title for the plot.
colors (list, optional, keyword-only) – The labels to color the samples, of size n_samples.
- Raises:
ValueError – If column_index is None and column_names_endog is not set, that has been set if the model has been initialized with a pd.DataFrame as endog.
ValueError – If the length of column_index is different from the length of column_names.
Examples
>>> from pyPLNmodels import PlnLDA, load_scrna >>> data = load_scrna() >>> lda = PlnLDA.from_formula("endog ~ 0 | labels", data=data) >>> lda.fit() >>> lda.biplot(column_names=["MALAT1", "ACTB"]) >>> lda.biplot(column_names=["A", "B"], column_index=[0, 4], colors=data["labels"])
- Raises:
ValueError – If the number of clusters is 2, as the latent variables will be of dimension and visualization is not possible.
- Parameters:
column_index (ndarray | None)
colors (ndarray | None)
title (str)
- property AIC
Akaike Information Criterion (AIC).
- property BIC
Bayesian Information Criterion (BIC) of the model.
- property ICL
Integrated Completed Likelihood criterion.
- property coef
Property representing the regression coefficients of size (nb_cov, dim). If no exogenous (exog) is available, returns None.
- Returns:
The coefficients or None if no coefficients are given in the model.
- Return type:
torch.Tensor or None
- property covariance
Property representing the covariance of the model.
- Returns:
The covariance.
- Return type:
torch.Tensor
- property dict_latent_parameters
The latent parameters of the model.
- property dim
Number of dimensions (i.e. variables) of the dataset.
- property elbo
Returns the last elbo computed.
- property endog
Property representing the endogenous variables (counts).
- Returns:
The endogenous variables.
- Return type:
torch.Tensor
- property entropy
Entropy of the latent variables.
- property exog
Property representing the exogenous variables (covariates).
- Returns:
The exogenous variables or None if no covariates are given in the model.
- Return type:
torch.Tensor or None
- get_coef_p_values()
Calculate the p-values for the regression coefficients. Returns None if there are no exogenous variables in the model.
- Returns:
p_values – P-values for the regression coefficients.
- Return type:
torch.Tensor
Examples
- get_confidence_interval_coef(alpha=0.05)
Calculate the confidence intervals for the regression coefficients. Returns None if there are no exogenous variables in the model.
- Parameters:
alpha (float (optional)) – Significance level for the confidence intervals. Defaults to 0.05.
- Returns:
interval_low, interval_high – Lower and upper bounds of the confidence intervals for the coefficients.
- Return type:
Tuple(torch.Tensor, torch.Tensor)
Examples
>>> import torch >>> from pyPLNmodels import Pln, PlnSampler >>> >>> sampler = PlnSampler(n_samples=1500, add_const=False, nb_cov=4) >>> endog = sampler.sample() # Sample Pln data. >>> >>> pln = Pln(endog, exog=sampler.exog, add_const=False) >>> pln.fit() >>> interval_low, interval_high = pln.get_confidence_interval_coef(alpha=0.05) >>> true_coef = sampler.coef >>> inside_interval = (true_coef > interval_low) & (true_coef < interval_high) >>> print('Should be around 0.95:', torch.mean(inside_interval.float()).item())
- get_variance_coef()
Calculate the variance of the regression coefficients using the sandwich estimator. Returns None if there are no exogenous variables in the model.
- Returns:
Variance of the regression coefficients.
- Return type:
torch.Tensor
- Raises:
ValueError – If the number of samples is less than the product of the number of covariates and dimensions.
Examples
- property latent_mean
Property representing the latent mean conditionally on the observed counts, i.e. the conditional mean of the latent variable of each sample.
- Returns:
The latent mean.
- Return type:
torch.Tensor
- property latent_parameters
Alias for dict_latent_parameters.
- property latent_positions
The (conditional) mean of the latent variables with the effect of covariates removed.
See also
Examples
>>> from pyPLNmodels import Pln, load_scrna >>> data = load_scrna() >>> pln = Pln.from_formula("endog ~ 1", data) >>> pln.fit() >>> print("Shape latent positions", pln.latent_positions.shape) >>> pln.viz(remove_exog_effect=True) # Visualize the latent positions
- property latent_sqrt_variance
Property representing the latent square root variance conditionally on the observed counts, i.e. the square root variance of the latent variable of each sample.
- Returns:
The square root of the latent variance.
- Return type:
torch.Tensor
- property latent_variance
Property representing the latent variance conditionally on the observed counts, i.e. the conditional variance of the latent variable of each sample.
- property list_of_parameters_needing_gradient
The list of all the parameters of the model that needs to be updated at each iteration.
- property loglike
Alias for elbo.
- property marginal_mean
The marginal mean of the model, i.e. the mean of the gaussian latent variable.
- property model_parameters
Alias for dict_model_parameters.
- property n_samples
Number of samples in the dataset.
- property nb_cov: int
The number of exogenous variables.
- property number_of_parameters
Returns the number of parameters of the model.
- property offsets
Property representing the offsets.
- Returns:
The offsets.
- Return type:
torch.Tensor
- property optim_details
Property representing the optimization details.
- Returns:
The dictionary of optimization details.
- Return type:
dict
- plot_regression_forest(alpha=0.05, figsize=(10, 10))
Creates a forest plot for regression coefficients with confidence intervals (5%).
- Parameters:
alpha (float) – The confidence parameter.
figsize (tuple) – The size of the figure.
- property precision
Property representing the precision of the model, that is the inverse covariance matrix.
- Returns:
The precision matrix of size (dim, dim).
- Return type:
torch.Tensor
- predict(array_like=None)
- projected_latent_variables(rank=2, remove_exog_effect=False)
Perform PCA on latent variables and return the projected variables.
- Parameters:
rank (int, optional) – The number of principal components to compute, by default 2.
remove_exog_effect (bool, optional) – Whether to remove or not the effect of exogenous variables. Default to False.
- Returns:
The projected variables.
- Return type:
numpy.ndarray
- show(savefig=False, name_file='', figsize=(10, 10))
Display the model parameters, norm evolution of the parameters and the criterion.
- Parameters:
savefig (bool, optional) – If True, the figure will be saved to a file. Default is False.
name_file (str, optional) – The name of the file to save the figure. Only used if savefig is True. Default is an empty string.
figsize (tuple of two positive floats.) – Size of the figure that will be created. By default (10,10)
- sigma()
Covariance of the model.
- summary()
Print a summary of the regression coefficients and their p-values for each dimension. Returns None if there are no exogenous variabes in the model.
Examples
- optim: torch.optim.Optimizer
List of methods and attributes
Public Data Attributes:
|
|
|
The clusters of each sample given in initialization. |
|
Marginal mean given only by the clusters mean, that is, the mean of each cluster. |
|
Regression coefficients for the cluster variable. |
|
The parameters of the model. |
|
The latent positions with effects coming only from the clusters covariates (effects of 'known' covariates remove). |
|
The (conditional) mean of the latent variables. |
|
Inherited from Pln
|
The list of all the parameters of the model that needs to be updated at each iteration. |
|
The parameters of the model. |
|
The latent parameters of the model. |
|
The (conditional) mean of the latent variables. |
|
The (conditional) mean of the latent variables with the effect of covariates removed. |
|
Returns the number of parameters of the model. |
|
Entropy of the latent variables. |
|
Inherited from BaseModel
|
|
|
The list of all the parameters of the model that needs to be updated at each iteration. |
|
The parameters of the model. |
|
Alias for dict_model_parameters. |
|
The latent parameters of the model. |
|
Alias for dict_latent_parameters. |
|
Number of samples in the dataset. |
|
Number of dimensions (i.e. variables) of the dataset. |
|
Property representing the endogenous variables (counts). |
|
Property representing the exogenous variables (covariates). |
|
The number of exogenous variables. |
|
Property representing the offsets. |
|
Property representing the latent mean conditionally on the observed counts, i.e. the conditional mean of the latent variable of each sample. |
|
Property representing the latent variance conditionally on the observed counts, i.e. the conditional variance of the latent variable of each sample. |
|
Property representing the latent square root variance conditionally on the observed counts, i.e. the square root variance of the latent variable of each sample. |
|
Property representing the regression coefficients of size (nb_cov, dim). |
|
Property representing the covariance of the model. |
|
Property representing the precision of the model, that is the inverse covariance matrix. |
|
The marginal mean of the model, i.e. the mean of the gaussian latent variable. |
|
The (conditional) mean of the latent variables. |
|
The (conditional) mean of the latent variables with the effect of covariates removed. |
|
Returns the last elbo computed. |
|
Alias for elbo. |
|
Bayesian Information Criterion (BIC) of the model. |
|
Integrated Completed Likelihood criterion. |
|
Akaike Information Criterion (AIC). |
|
Returns the number of parameters of the model. |
|
Entropy of the latent variables. |
|
Property representing the optimization details. |
|
Public Methods:
|
Initializes the model class. |
|
Create a model instance from a formula and data. |
|
Fit the model using variational inference. |
|
Compute the elbo of the current parameters. |
|
Predict the clusters of the given endog and exog. |
|
Visualize the latent variables. |
|
Plot the predicted value of the endog against the endog. |
|
Transform the endog into the learned LDA space. |
|
Transform the (unseen) endog data into the previously learned LDA space. |
|
Visualize the transformed data in the LDA space. |
|
Generates a scatter matrix plot based on Principal Component Analysis (PCA) on the latent variables. |
|
Visualizes variables using PCA and plots a correlation circle. |
|
Visualizes variables using the correlation circle along with the pca transformed samples. |
Inherited from Pln
|
Initializes the model class. |
|
Create an instance from a formula and data. |
|
Fit the model using variational inference. |
|
Compute the elbo of the current parameters. |
|
Visualizes variables using PCA and plots a correlation circle. |
|
Visualizes variables using the correlation circle along with the pca transformed samples. |
|
Generates a scatter matrix plot based on Principal Component Analysis (PCA) on the latent variables. |
|
Returns the latent variables. |
|
Plot the predicted value of the endog against the endog. |
|
Visualize the latent variables. |
|
Calculate the variance of the regression coefficients using the sandwich estimator. |
|
Calculate the confidence intervals for the regression coefficients. |
|
Calculate the p-values for the regression coefficients. |
|
Print a summary of the regression coefficients and their p-values for each dimension. |
|
Creates a forest plot for regression coefficients with confidence intervals (5%). |
Inherited from BaseModel
|
Initializes the model class. |
|
Create an instance from a formula and data. |
|
Fit the model using variational inference. |
|
Display the model parameters, norm evolution of the parameters and the criterion. |
|
Visualizes variables using PCA and plots a correlation circle. |
|
Visualizes variables using the correlation circle along with the pca transformed samples. |
|
Compute the elbo of the current parameters. |
|
Perform PCA on latent variables and return the projected variables. |
|
Returns the latent variables. |
|
Visualize the latent variables. |
|
Generate the string representation of the model. |
|
|
|
Covariance of the model. |
|
Generates a scatter matrix plot based on Principal Component Analysis (PCA) on the latent variables. |
|
Plot the predicted value of the endog against the endog. |
Private Data Attributes:
|
Marginal mean that takes both the exog and known clusters as covariates |
|
|
|
|
|
|
|
|
|
|
|
The methods that are specific to this model. |
|
The attributes that are specific to this model. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Inherited from Pln
|
Description of the model. |
|
|
|
|
|
The attributes that are specific to this model. |
|
The methods that are specific to this model. |
|
Abstract method the predict the endog variables. |
|
|
|
|
|
|
|
|
|
Inherited from BaseModel
|
|
|
Description of the model. |
|
|
|
|
|
|
|
|
|
|
|
|
|
The attributes that are specific to this model. |
|
The methods that are specific to this model. |
|
Property representing the dictionary for printing. |
|
Abstract method the predict the endog variables. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inherited from ABC
|
Private Methods:
|
|
|
|
|
Inherited from Pln
|
The model parameters are profiled in the ELBO, no need to initialize them. |
|
Initialization of latent parameters. |
|
Computes the covariance when the latent variables are embedded in a lower dimensional space (often 2) with sklearn_components. |
Inherited from BaseModel
|
|
|
Compute the elbo and do a gradient step. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Initialization of model parameters. |
|
Initialization of latent parameters. |
|
Move parameters to the GPU device if present. |
|
|
|
|
|
Project some parameters such as probabilities. |
|
Update some parameters. |
|
|
|
Print the training statistics. |
|
Perform PCA on latent variables and return the projected variables along with their covariances in the two dimensional space. |
|
Computes the covariance when the latent variables are embedded in a lower dimensional space (often 2) with sklearn_components. |