vbvarsel.calcparams
Functions
|
Function to find the updated variational parameter alphaK, i.e., the concentration parameter for Dirichelet posterior distribution on the mixture proportions |
|
Function to calculate the updated variational parameter akj |
|
Function to find Xd. |
|
Function to calculate Skj. |
|
Function to calculate the updated variational parameter betaKJ. |
|
Function to calculate the updated variational parameter Mkj |
|
Function to calculate the updated variational parameter B |
|
Function to calculate the updated variational parameter Delta |
|
Function to calculate the expected Sigma values. |
|
Function to calculate Expected Pi value |
|
Function to calculate Expected Tau value |
|
Function to calculate F0 |
|
Function to the updated variational parameter Z, the latent cluster assignments |
|
Function to get a normal distribution |
|
Function to calculate expected F, an intermediate factor to calculate the updated covariate selection indicators |
|
Function to calculate expected F0, an intermediate factor to calculate the updated covariate selection indicators |
|
Function to calculate N1, a parameter for Cj in the Bernoulli distribution |
|
Function to calculate N2 , a parameter for Cj in the Bernoulli distribution |
|
Function to calculate the updated variational parameter C, the covariate selection indicators |
Module Contents
- vbvarsel.calcparams.calcAlphak(NK: float, alpha0: float, T: float) float [source]
Function to find the updated variational parameter alphaK, i.e., the concentration parameter for Dirichelet posterior distribution on the mixture proportions
- Params
- NK: float
Number of observations assigned to each cluster K
- alpha0: float
Prior coefficient count,
alpha0()
- T: float
Annealing temperature
- Returns
- alphaK: np.ndarray[float]
Calculated Alphak values
- vbvarsel.calcparams.calcAkj(K: int, J: int, C: numpy.ndarray[float], NK: float, a0: float, T: float) numpy.ndarray[float] [source]
Function to calculate the updated variational parameter akj
- Params
- Returns
- akj: float
updated variational parameter for the degrees of freedom of the posterior Gamma distribution
- vbvarsel.calcparams.calcXd(Z: numpy.ndarray, X: numpy.ndarray[float]) numpy.ndarray[float] [source]
Function to find Xd.
- Params
- Z: np.ndarray
Latent cluster assignment matrix,
calcZ()
- X: np.ndarray[float]
2-D array of normalised data
- Returns
- xd: np.ndarray[float]
Array of values
- vbvarsel.calcparams.calcS(Z: numpy.ndarray, X: numpy.ndarray[float], xd: numpy.ndarray[float]) numpy.ndarray[float] [source]
Function to calculate Skj.
- vbvarsel.calcparams.calcbetakj(K: int, XDim: int, C: numpy.ndarray[int], NK: float, beta0: float, T: float) numpy.ndarray[float] [source]
Function to calculate the updated variational parameter betaKJ.
- Params
- Returns
- beta: np.ndarray[float]
Updated variational shrinkage parameter for the Gaussian conditional posterior
- vbvarsel.calcparams.calcM(K: int, XDim: int, beta0: float, m0: float, NK: float, xd: numpy.ndarray[float], betakj: numpy.ndarray[float], C: numpy.ndarray[int], T: float) numpy.ndarray[float] [source]
Function to calculate the updated variational parameter Mkj
- Params
- K: int
The Kth cluster
- XDim: int
number of variables (columns)
- beta0: float
Shrinkage parameter of the Gaussian conditional prior,
beta0()
- m0: float
Prior cluster means
- NK: float
Number of observations assigned to each cluster K
- xd: np.ndarray[float]
Value of calculated variational parameter xd, ,
calcXd()
- betakj: np.ndarray[float]
Updated variational shrinkage parameter for the Gaussian conditional posterior
- C: np.ndarray[int]
Covariate selection indicators,
calcC()
- T: float
Annealing temperature,
t_max()
- Returns
- m: np.ndarray[float]
Updated variational cluster means
- vbvarsel.calcparams.calcB(W0, xd, K, m0, XDim, beta0, S, C, NK, T) numpy.ndarray[float] [source]
Function to calculate the updated variational parameter B
- Params
- W0: np.ndarray[float]
2-D array with diagonal 1s rest 0s
- xd: np.ndarray[float]
Value of calculated variational parameter xd,
calcXd()
- K: int
Hyperparameter k1, the number of clusters
- m0: np.ndarray[int]
Array of 0s with same shape as test data
- XDim: int
Number of variables (columns)
- beta0: float
Shrinkage parameter of the Gaussian conditional prior on the cluster mean,
beta0()
- S: list[np.ndarray[float]]
Calculated value of variational paramater S,
calcS()
- C: np.ndarray[float]
Covariate selection indicators,
calcC()
- NK: float
Number of observations assigned to each cluster K
- T: float
Annealing temperature,
t_max()
- Returns
- B: np.ndarray[float]
Calculated variational parameter B
- vbvarsel.calcparams.calcDelta(C: numpy.ndarray[float], d: int, T: float) numpy.ndarray[float] [source]
Function to calculate the updated variational parameter Delta
- vbvarsel.calcparams.expSigma(X: numpy.ndarray[float], XDim: int, betak: float, m: numpy.ndarray[float], b: numpy.ndarray[float], a: numpy.ndarray[float], C: numpy.ndarray[float]) float [source]
Function to calculate the expected Sigma values.
- Params
- X: np.ndarray[float]
2-D normalised array of data
- XDim: int
Number of variables (columns)
- betak: float
Calculated value for the variational paramater betakj,
calcbetakj()
- m: np.ndarray[float]
Calculated value for the variational paramater m,
calcM()
- b: np.ndarray[float]
Calculated value for the variational paramater B,
calcB()
- a: np.ndarray[float]
Calculated value for the variational paramater akj,
calcAkj()
- C: np.ndarray[int]
Covariate selection indicators,
calcC()
- Returns
- s: float
Calculated expected sigma values
- vbvarsel.calcparams.expPi(alpha0: float, NK: float) numpy.ndarray[float] [source]
Function to calculate Expected Pi value
- Params
- alpha0: float
Concentration of the Dirichlet prior on the mixture weights π,
alpha0()
- NK: float
Number of expected observations associated with the Kth component
- Returns
- pik: np.ndarray[float]
Expected values of pi
- vbvarsel.calcparams.expTau(bkj: numpy.ndarray[float], akj: numpy.ndarray[float], C: numpy.ndarray[int]) list[float] [source]
Function to calculate Expected Tau value
- vbvarsel.calcparams.calcF0(X: numpy.ndarray[float], XDim: int, sigma_0: numpy.ndarray[float], mu_0: numpy.ndarray[float], C: numpy.ndarray[float]) float [source]
Function to calculate F0
- Params
- X: np.ndarray
2-D array of normalised data
- XDim: int
Number of variables (columns)
- sigma_0: np.ndarray
Paramater estimate for Phi0j as MLE
- mu_0: np.ndarray
Paramater estimate for Phi0j as MLE
- C: np.ndarray
Covariate selection indicators,
calcC()
- Returns
- F0: np.ndarray
Calculated value for variational parameter F0
- vbvarsel.calcparams.calcZ(exp_ln_pi: numpy.ndarray[float], exp_ln_tau: numpy.ndarray[float], exp_ln_sigma: numpy.ndarray[float], f0: float, N: int, K: int, C: numpy.ndarray[float], T: float) numpy.ndarray[float] [source]
Function to the updated variational parameter Z, the latent cluster assignments
- Params
- exp_ln_pi: np.ndarray
Expected natural log of pi,
expPi()
- exp_ln_tau: np.ndarray
Expected natural log of tau,
expTau()
- exp_ln_sigma: np.ndarray
Expected natural log of sigma,
expSigma()
- f0: float
Calculated f0 value,
calcF0()
- N: int
The nth observation
- K: int
The kth cluster of the observation
- C: np.ndarray
Covariate selection indicators,
calcC()
- T: float
Annealing temperature,
t_max()
- Returns
- Z: np.ndarray
Calculated variational parameter Z
- vbvarsel.calcparams.normal(x: numpy.ndarray[float], mu: float, sigma: numpy.ndarray[float]) numpy.ndarray[float] [source]
Function to get a normal distribution
- Params
- x: np.ndarray
2-D array of normalised data
- mu: float
Mean of the normal distribution
- sigma: np.ndarray
Standard deviation of the normal distribution
- Returns
- n: np.ndarray
Array with normalised distribution
- vbvarsel.calcparams.calcexpF(X: numpy.ndarray[float], b: numpy.ndarray[float], a: numpy.ndarray[float], m: numpy.ndarray[float], beta: numpy.ndarray[float], Z: numpy.ndarray[float]) float [source]
Function to calculate expected F, an intermediate factor to calculate the updated covariate selection indicators
- Params
- X: np.ndarray
2-D array of normalised data
- b: np.ndarray
Value for the calculated variational parameter B,
calcB()
- a: np.ndarray
Value for the calculated variational parameter akj,
calcAkj()
- m: np.ndarray
Value for the calculated variational parameter m,
calcM()
- beta: np.ndarray
Value for the calculated variational parameter betakj,
calcbetakj()
- Z: np.ndarray
Latent cluster assignment matrix,
calcZ()
- Returns
- expF: float
Intermediate factor to calculate the updated covariate selection indicators
- vbvarsel.calcparams.calcexpF0(X: numpy.ndarray[float], N: int, K: int, XDim: int, Z: numpy.ndarray, sigma_0: numpy.ndarray[float], mu_0: numpy.ndarray[float]) numpy.ndarray[float] [source]
Function to calculate expected F0, an intermediate factor to calculate the updated covariate selection indicators
- Params
- X: np.ndarray
2-D array of normalised data
- N: int
The nth observation
- K: int
The kth cluster of the observation
- XDim: int
Number of variables (columns)
- Z: np.ndarray
Latent cluster assignment matrix,
calcZ()
- sigma_0: np.ndarray
N-dim array of squared sigma values
- mu_0: np.ndarray
N-dim array of squared mu values
- Returns
- expF0: np.ndarray
Expected F0, an intermediate factor to calculate the updated covariate selection indicators
- vbvarsel.calcparams.calcN1(C: numpy.ndarray[int], d: int, expF: float, T: float) tuple [source]
Function to calculate N1, a parameter for Cj in the Bernoulli distribution
- Params
- C: np.ndarray
Covariate selection indicators,
calcC()
- d: int
Shape parameter of the Beta distribution on the probability.
d0()
- expF: float
Intermediate factor to calculate the updated covariate selection indicators
calcexpF()
- T: float
Annealing temperature,
t_max()
- Returns
- N1, lnN1: tuple
Intermediate factors to calculate the updated covariate selection indicators
- vbvarsel.calcparams.calcN2(C: numpy.ndarray[int], d: int, expF0: float, T: float) tuple [source]
Function to calculate N2 , a parameter for Cj in the Bernoulli distribution
- Params
- C: np.ndarray
Covariate selection indicators,
calcC()
- d: int
Shape parameter of the Beta distribution on the probability.
d0()
- expF0: float
Intermediate factor to calculate the updated covariate selection indicators
calcexpF0()
- T: float
Annealing temperature,
t_max()
- Returns
- N2, lnN2: tuple
Intermediate factors to calculate the updated covariate selection indicators
- vbvarsel.calcparams.calcC(XDim: int, N: int, K: int, X: numpy.ndarray[float], b: numpy.ndarray[float], a: numpy.ndarray[float], m: numpy.ndarray[float], beta: numpy.ndarray[float], d: int, C: numpy.ndarray[float], Z: numpy.ndarray, sigma_0: numpy.ndarray[float], mu_0: numpy.ndarray[float], T: float, trick: bool = False) numpy.ndarray[float] [source]
Function to calculate the updated variational parameter C, the covariate selection indicators
- Params
- XDim: int
Number of variables (columns)
- N: int
the nth observation
- K: int
the kth cluster of the observation
- X: np.ndarray
2-D array of normalised data
- b: np.ndarray
Calculated variational paramater B, derived from
calcB()
- a: np.ndarray
Calculated variational paramater akj, derived from
calcAkj()
- m: np.ndarray
Calculated variational paramater m, derived from
calcM()
- beta: np.ndarray
Calculated variational paramater betakj, derived from
calcbetakj()
- d: int
Shape parameter of the Beta distribution on the probability.
- C: np.ndarray
Covariate selection indicators,
calcC()
- Z: np.ndarray
Latent cluster assignment matrix
- sigma_0: np.ndarray
N-dimensional array of squared sigma values
- mu_0: np.ndarray
N-dimensional array of squared mu values
- T: float
Annealing temperature,
t_max()
- trick: bool (Optional) (Default: True)
Flag for whether or not to use a mathematical trick to avoid numerical errors
- Returns
- C0: np.ndarray
Calculated variational parameter C