mofaflex.priors.GaussianProcess#
- class mofaflex.priors.GaussianProcess(covariates_key=None, covariates_mkey=None, n_inducing=100, kernel='RBF', mefisto_kernel=True, independent_lengthscales=False, group_covar_rank=1, warp=False, warp_interval=20, warp_open_begin=True, warp_open_end=True, warp_reference_group=None)#
Gaussian process prior for spatially or temporally smooth factors.
Important
All methods and properties of this class are only accessible through the
MofaFlexclass.- Parameters:
covariates_key (
str|Mapping[str] |None(default:None)) – The column of.obs/.varthat contains covariate values. Cannot be used together withcovariates_mkey.covariates_mkey (
str|Mapping[str] |None(default:None)) – The key in.obsm/.varmthat contains covariate values. Cannot be used together withcovariates_key.n_inducing (
int(default:100)) – Number of inducing points.kernel (
Literal['RBF','Matern'] (default:'RBF')) – Kernel function to use.mefisto_kernel (
bool(default:True)) – Whether to use the MEFISTO group covariance kernel or treat groups independently.independent_lengthscales (
bool(default:False)) – Whether to use a separate lengthscale per covariate dimension.group_cvar_rank – Rank of the group correlation matrix. Only relevant if
mefisto_kernel=True.warp (
bool(default:False)) – Whether to use dynamic time warping. Warping is only supported for 1D covariates.warp_interval (
int(default:20)) – Apply dynamic time warping everywarp_intervalepochs.warp_open_begin (
bool(default:True)) – Perform open-ended alignment.warp_open_end (
bool(default:True)) – Perform open-ended alignment.warp_reference_group (
str|None(default:None)) – Reference group to align the others to. Defaults to the first group.
Attributes table#
Covariates for each group.
Covariate names for each group where they could be inferred from the input.
Between-group correlation for each factor.
Inferred lengthscales for each factor.
Inferred variance scales (smoothness) for each factor.
Time-warped covariates for each group, if dynamic time warping was enabled.
Time-warped covariates for each group, if dynamic time warping was enabled.
Covariates for each group.
Covariate names for each group where they could be inferred from the input.
Between-group correlation for each factor.
Inferred lengthscales for each factor.
Inferred variance scales (smoothness) for each factor.
Methods table#
get_factor_gps([moment, x, batch_size, ordered])Get all latent functions.
get_weight_gps([moment, x, batch_size, ordered])Get all latent functions.
Attributes#
- property factor_covariates: Mapping[str, ndarray[tuple[int, int], floating]]#
Covariates for each group.
- property factor_covariates_names: dict[str, ndarray[tuple[int, int], str | str_]]#
Covariate names for each group where they could be inferred from the input.
- property factor_gp_group_correlation: ndarray[tuple[int, int], floating]#
Between-group correlation for each factor.
- property factor_gp_lengthscale: ndarray[tuple[int], floating] | ndarray[tuple[int, int], floating]#
Inferred lengthscales for each factor.
- property factor_gp_scale: ndarray[tuple[int], floating]#
Inferred variance scales (smoothness) for each factor.
- property warped_factor_covariates: Mapping[str, ndarray[tuple[int, int], floating]] | None#
Time-warped covariates for each group, if dynamic time warping was enabled.
- property warped_weight_covariates: Mapping[str, ndarray[tuple[int, int], floating]] | None#
Time-warped covariates for each group, if dynamic time warping was enabled.
- property weight_covariates: Mapping[str, ndarray[tuple[int, int], floating]]#
Covariates for each group.
- property weight_covariates_names: dict[str, ndarray[tuple[int, int], str | str_]]#
Covariate names for each group where they could be inferred from the input.
- property weight_gp_group_correlation: ndarray[tuple[int, int], floating]#
Between-group correlation for each factor.
Methods#
- get_factor_gps(moment: Literal['mean', 'std'] = 'mean', x: Mapping[str, ndarray[tuple[int, int], T] | Tensor] | None = None, batch_size: int | None = None, ordered: bool = False) Mapping[str, DataFrame]#
Get all latent functions.
- Parameters:
moment (
Literal['mean','std'] (default:'mean')) – Which moment of the posterior distribution to return.x (
Mapping[str,ndarray[tuple[int,int],TypeVar(T,int,float,complex,bool,bytes,str,memoryview,bool,csingle,cdouble,clongdouble,half,single,double,longdouble,byte,short,intc,int_,longlong,datetime64,timedelta64,object_,bytes_,str_,ubyte,ushort,uintc,uint,ulonglong,void)] |Tensor] |None(default:None)) – Covariate values for each group. IfNone, will return latent function values at covariate coordinates used for training.batch_size (
int|None(default:None)) – Minibatch size. Only has an effect ifxis notNone. Defaults to the minibatch size used for training.ordered (
bool(default:False)) – Whether to return the factors ordered by explained variance (highest to lowest).
- Return type:
- get_weight_gps(moment: Literal['mean', 'std'] = 'mean', x: Mapping[str, ndarray[tuple[int, int], T] | Tensor] | None = None, batch_size: int | None = None, ordered: bool = False) Mapping[str, DataFrame]#
Get all latent functions.
- Parameters:
moment (
Literal['mean','std'] (default:'mean')) – Which moment of the posterior distribution to return.x (
Mapping[str,ndarray[tuple[int,int],TypeVar(T,int,float,complex,bool,bytes,str,memoryview,bool,csingle,cdouble,clongdouble,half,single,double,longdouble,byte,short,intc,int_,longlong,datetime64,timedelta64,object_,bytes_,str_,ubyte,ushort,uintc,uint,ulonglong,void)] |Tensor] |None(default:None)) – Covariate values for each group. IfNone, will return latent function values at covariate coordinates used for training.batch_size (
int|None(default:None)) – Minibatch size. Only has an effect ifxis notNone. Defaults to the minibatch size used for training.ordered (
bool(default:False)) – Whether to return the factors ordered by explained variance (highest to lowest).
- Return type: