1.1.3. svGPFA.stats package#

1.1.3.1. Submodules#

1.1.3.2. svGPFA.stats.expectedLogLikelihood module#

class svGPFA.stats.expectedLogLikelihood.ExpectedLogLikelihood(svEmbeddingAllTimes, linkFunction)[source]#

Bases: ABC

abstract buildKernelsMatrices()[source]#
computeEmbeddingsMeansAndVarsAtTimes(times)[source]#
computeExpectedPosteriorCIFs(times)[source]#
abstract computeSVPosteriorOnLatentsStats()[source]#
abstract evalSumAcrossTrialsAndNeurons(svPosteriorOnLatentsStats=None)[source]#
getIndPointsLocs()[source]#
getKernels()[source]#
getKernelsParams()[source]#
getSVEmbeddingParams()[source]#
getSVPosteriorOnIndPointsParams()[source]#
get_svEmbeddingAllTimes()[source]#
predictEmbedding(times)[source]#
predictLatents(times)[source]#
sampleCIFs(times, nudget=0.001)[source]#
abstract setELLCalculationParams(eLLCalculationParams)[source]#
abstract setIndPointsLocs(locs)[source]#
abstract setInitialParams(initial_params)[source]#
abstract setKernels(kernels)[source]#
abstract setMeasurements(measurements)[source]#
setPriorCovRegParam(priorCovRegParam)[source]#
class svGPFA.stats.expectedLogLikelihood.PointProcessELL(svEmbeddingAllTimes, svEmbeddingAssocTimes, linkFunction)[source]#

Bases: ExpectedLogLikelihood

buildKernelsMatrices()[source]#
computeSVPosteriorOnLatentsStats()[source]#
evalSumAcrossTrialsAndNeurons(svPosteriorOnLatentsStats=None)[source]#
setELLCalculationParams(eLLCalculationParams)[source]#
setIndPointsLocs(locs)[source]#
setInitialParams(initial_params)[source]#
setKernels(kernels)[source]#
setMeasurements(measurements)[source]#

Bases: PointProcessELL

class svGPFA.stats.expectedLogLikelihood.PointProcessELLQuad(svEmbeddingAllTimes, svEmbeddingAssocTimes, linkFunction)[source]#

Bases: PointProcessELL

setELLCalculationParams(eLLCalculationParams)[source]#
class svGPFA.stats.expectedLogLikelihood.PoissonELL(svEmbeddingAllTimes, linkFunction)[source]#

Bases: ExpectedLogLikelihood

buildKernelsMatrices()[source]#
computeSVPostOnLatentsStats()[source]#
computeSVPosteriorOnLatentsStats()[source]#
evalSumAcrossTrialsAndNeurons(svPosteriorOnLatentsStats=None)[source]#
setELLCalculationParams(eLLCalculationParams)[source]#
setIndPointsLocs(locs)[source]#
setInitialParams(initial_params)[source]#
setKernels(kernels)[source]#
setMeasurements(measurements)[source]#

Bases: PoissonELL

class svGPFA.stats.expectedLogLikelihood.PoissonELLQuad(svEmbeddingAllTimes, linkFunction)[source]#

Bases: PoissonELL

1.1.3.3. svGPFA.stats.kernels module#

class svGPFA.stats.kernels.ExponentialQuadraticKernel(scale=1.0, lengthscaleScale=1.0, dtype=torch.float64)[source]#

Bases: Kernel

buildKernelMatrix(X1, X2=None)[source]#
buildKernelMatrixDiag(X)[source]#
getNamedParams()[source]#
getScaledParams()[source]#
class svGPFA.stats.kernels.Kernel[source]#

Bases: ABC

abstract buildKernelMatrix(X1, X2=None)[source]#
abstract buildKernelMatrixDiag(X)[source]#
abstract getNamedParams()[source]#
getParams()[source]#
setParams(params)[source]#
class svGPFA.stats.kernels.PeriodicKernel(scale=1.0, lengthscaleScale=1.0, periodScale=1.0, dtype=torch.float64)[source]#

Bases: Kernel

buildKernelMatrix(X1, X2=None)[source]#
buildKernelMatrixDiag(X)[source]#
getNamedParams()[source]#
getScaledParams()[source]#

1.1.3.4. svGPFA.stats.kernelsMatricesStore module#

class svGPFA.stats.kernelsMatricesStore.IndPointsLocsAndAllTimesKMS[source]#

Bases: IndPointsLocsAndTimesKMS

buildKernelsMatrices()[source]#
buildKttKernelsMatrices()[source]#
class svGPFA.stats.kernelsMatricesStore.IndPointsLocsAndAssocTimesKMS[source]#

Bases: IndPointsLocsAndTimesKMS

buildKernelsMatrices()[source]#
class svGPFA.stats.kernelsMatricesStore.IndPointsLocsAndTimesKMS[source]#

Bases: KernelsMatricesStore

getKtt()[source]#
getKttDiag()[source]#
getKtz()[source]#
setTimes(times)[source]#
class svGPFA.stats.kernelsMatricesStore.IndPointsLocsKMS[source]#

Bases: KernelsMatricesStore

buildKernelsMatrices()[source]#
getKzz()[source]#
getRegParam()[source]#
setRegParam(reg_param)[source]#
abstract solveForLatent(input, latentIndex)[source]#
abstract solveForLatentAndTrial(input, latentIndex, trialIndex)[source]#
class svGPFA.stats.kernelsMatricesStore.IndPointsLocsKMS_Chol[source]#

Bases: IndPointsLocsKMS

solveForLatent(input, latentIndex)[source]#
solveForLatentAndTrial(input, latentIndex, trialIndex)[source]#
class svGPFA.stats.kernelsMatricesStore.IndPointsLocsKMS_CholWithGettersAndSetters[source]#

Bases: IndPointsLocsKMS_Chol, KernelMatricesStoreGettersAndSetters

class svGPFA.stats.kernelsMatricesStore.IndPointsLocsKMS_PInv[source]#

Bases: IndPointsLocsKMS

solveForLatent(input, latentIndex)[source]#
solveForLatentAndTrial(input, latentIndex, trialIndex)[source]#
class svGPFA.stats.kernelsMatricesStore.IndPointsLocsKMS_PInvWithGettersAndSetters[source]#

Bases: IndPointsLocsKMS_PInv, KernelMatricesStoreGettersAndSetters

class svGPFA.stats.kernelsMatricesStore.KernelMatricesStoreGettersAndSetters[source]#

Bases: ABC

get_flattened_ind_points_locs()[source]#
get_flattened_ind_points_locs_grad()[source]#
get_flattened_kernels_params()[source]#
get_flattened_kernels_params_grad()[source]#
set_ind_points_locs_from_flattened(flattened_params)[source]#
set_ind_points_locs_requires_grad(requires_grad)[source]#
set_kernels_params_from_flattened(flattened_params)[source]#
set_kernels_params_requires_grad(requires_grad)[source]#
class svGPFA.stats.kernelsMatricesStore.KernelsMatricesStore[source]#

Bases: ABC

abstract buildKernelsMatrices()[source]#
getIndPointsLocs()[source]#
getKernels()[source]#
getKernelsParams()[source]#
setIndPointsLocs(ind_points_locs)[source]#
setInitialParams(initial_params)[source]#
setKernels(kernels)[source]#
setKernelsParams(kernels_params)[source]#

1.1.3.5. svGPFA.stats.klDivergence module#

class svGPFA.stats.klDivergence.KLDivergence(indPointsLocsKMS, svPosteriorOnIndPoints)[source]#

Bases: object

evalSumAcrossLatentsAndTrials()[source]#
get_indPointsLocsKMS()[source]#
get_svPosteriorOnIndPoints()[source]#

1.1.3.6. svGPFA.stats.svEM module#

class svGPFA.stats.svEM.ErrorTerminationInfo(message, error, stack_trace)[source]#

Bases: TerminationInfo

property error#
property stack_trace#
class svGPFA.stats.svEM.SVEM[source]#

Bases: ABC

abstract maximize(model, optim_params, method='ECM', getIterationModelParamsFn=None, printIterationModelParams=True, logLock=None, logStreamFN=None, lowerBoundLock=None, lowerBoundStreamFN=None, latentsTimes=None, latentsLock=None, latentsStreamFN=None, verbose=True, out=<sphinx_gallery.gen_rst._LoggingTee object>, savePartial=False, savePartialFilenamePattern='results/00000000_{:s}_estimatedModel.pickle')[source]#

Maximizes the sparse variational lower bound, Eq. 4 in Duncker and Sahani, 2018.

Note

Only parameters model, optim_params and method should be set by users. The remaining parameters are used to interface svGPFA.stats.svEM.SVEM.maximize() with the dashboard.

Parameters:
class svGPFA.stats.svEM.SVEM_PyTorch[source]#

Bases: SVEM

maximize(model, optim_params, method='ECM', getIterationModelParamsFn=None, printIterationModelParams=True, logLock=None, logStreamFN=None, lowerBoundLock=None, lowerBoundStreamFN=None, latentsTimes=None, latentsLock=None, latentsStreamFN=None, verbose=True, out=<sphinx_gallery.gen_rst._LoggingTee object>, savePartial=False, savePartialFilenamePattern='results/00000000_{:s}_estimatedModel.pickle')[source]#

Maximizes the sparse variational lower bound, Eq. 4 in Duncker and Sahani, 2018.

Note

Only parameters model, optim_params and method should be set by users. The remaining parameters are used to interface svGPFA.stats.svEM.SVEM.maximize() with the dashboard.

Parameters:
class svGPFA.stats.svEM.SVEM_SciPy[source]#

Bases: SVEM

maximize(model, optim_params, method='EM', getIterationModelParamsFn=None, printIterationModelParams=True, logLock=None, logStreamFN=None, lowerBoundLock=None, lowerBoundStreamFN=None, latentsTimes=None, latentsLock=None, latentsStreamFN=None, verbose=True, out=<sphinx_gallery.gen_rst._LoggingTee object>, savePartial=False, savePartialFilenamePattern='00000000_{:s}_estimatedModel.pickle')[source]#

Maximizes the sparse variational lower bound, Eq. 4 in Duncker and Sahani, 2018.

Note

Only parameters model, optim_params and method should be set by users. The remaining parameters are used to interface svGPFA.stats.svEM.SVEM.maximize() with the dashboard.

Parameters:
class svGPFA.stats.svEM.TerminationInfo(message)[source]#

Bases: object

property message#

1.1.3.7. svGPFA.stats.svEmbedding module#

class svGPFA.stats.svEmbedding.LinearSVEmbedding(svPosteriorOnLatents)[source]#

Bases: SVEmbedding

getParams()[source]#
sample(times, nudget=0.001)[source]#
setInitialParams(initial_params)[source]#
class svGPFA.stats.svEmbedding.LinearSVEmbeddingAllTimes(svPosteriorOnLatents)[source]#

Bases: LinearSVEmbedding

computeMeansAndVarsAtTimes(times)[source]#
predict(times)[source]#
predictLatents(times)[source]#
setPriorCovRegParam(priorCovRegParam)[source]#
class svGPFA.stats.svEmbedding.LinearSVEmbeddingAllTimesWithParamsGettersAndSetters(svPosteriorOnLatents)[source]#

Bases: LinearSVEmbeddingAllTimes

get_flattened_params()[source]#
get_flattened_params_grad()[source]#
set_params_from_flattened(flattened_params)[source]#
set_params_requires_grad(requires_grad)[source]#
class svGPFA.stats.svEmbedding.LinearSVEmbeddingAssocTimes(svPosteriorOnLatents)[source]#

Bases: LinearSVEmbedding

setNeuronForSpikeIndex(neuronForSpikeIndex)[source]#
class svGPFA.stats.svEmbedding.SVEmbedding(svPosteriorOnLatents)[source]#

Bases: ABC

buildKernelsMatrices()[source]#
computeMeansAndVars(svPosteriorOnLatentsStats=None)[source]#
computeSVPosteriorOnLatentsStats()[source]#
getIndPointsLocs()[source]#
getKernels()[source]#
getKernelsParams()[source]#
abstract getParams()[source]#
getSVPosteriorOnIndPointsParams()[source]#
setIndPointsLocs(indPointsLocs)[source]#
abstract setInitialParams(initial_params)[source]#
setKernels(kernels)[source]#
setTimes(times)[source]#

1.1.3.8. svGPFA.stats.svGPFAModelFactory module#

svGPFA.stats.svGPFAModelFactory.Gaussian = 2#
svGPFA.stats.svGPFAModelFactory.LinearEmbedding = 100#
svGPFA.stats.svGPFAModelFactory.PointProcess = 0#
svGPFA.stats.svGPFAModelFactory.Poisson = 1#
class svGPFA.stats.svGPFAModelFactory.SVGPFAModelFactory[source]#

Bases: object

static buildModelPyTorch(kernels, conditionalDist=0, linkFunction=1000, embeddingType=100, kernelMatrixInvMethod=10000, indPointsCovRep=100001)[source]#

Creates an svGPFA model. svGPFA.stats.svLowerBound.SVLowerBound.setInitialDataAndParams() should be invoked before using the created model as argument to svGPFA.stats.svEM.SVEM.maximize().

Parameters:
  • kernels (list of instances from subclass of (svGPFA.stats.kernel.Kernel)) – list of kernels (svGPFA.stats.kernel) to be used in the model

  • conditionalDist (int) – likelihood distribution (e.g., svGPFA.stats.SVGPFAModelFactory.PointProcess or svGPFA.stats.SVGPFAModelFactory.Gaussian)

  • embeddingType (int) – type of embedding (e.g., svGPFA.stats.SVGPFAModelFactory.LinearEmbedding)

Returns:

an unitialized model. Parameters and data need to be set (by calling svGPFA.stats.svLowerBound.SVLowerBound.setParamsAndData()) before invoking svGPFA.stats.svEM.SVEM.maximize().

Return type:

an instance of svGPFA.stats.svLowerBound.SVLowerBound.

static buildModelSciPy(conditionalDist, linkFunction, embeddingType, kernels, kernelMatrixInvMethod, indPointsCovRep)[source]#
svGPFA.stats.svGPFAModelFactory.indPointsCovChol = 100001#
svGPFA.stats.svGPFAModelFactory.indPointsCovRank1PlusDiag = 100000#
svGPFA.stats.svGPFAModelFactory.kernelMatrixInvChol = 10000#
svGPFA.stats.svGPFAModelFactory.kernelMatrixInvPInv = 10001#

1.1.3.9. svGPFA.stats.svLBFGS module#

class svGPFA.stats.svLBFGS.ErrorTerminationInfo(message, error)[source]#

Bases: TerminationInfo

property error#
class svGPFA.stats.svLBFGS.SVLBFGS[source]#

Bases: object

maximize(model, optimParams, method='EM', getIterationModelParamsFn=None, logLock=None, logStreamFN=None, lowerBoundLock=None, lowerBoundStreamFN=None, latentsTimes=None, latentsLock=None, latentsStreamFN=None, verbose=True, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, savePartial=False, savePartialFilenamePattern='00000000_{:s}_estimatedModel.pickle')[source]#
class svGPFA.stats.svLBFGS.TerminationInfo(message)[source]#

Bases: object

property message#

1.1.3.10. svGPFA.stats.svLowerBound module#

class svGPFA.stats.svLowerBound.SVLowerBound(eLL, klDiv)[source]#

Bases: object

buildKernelsMatrices()[source]#
computeEmbeddingMeansAndVarsAtTimes(times)[source]#
computeExpectedPosteriorCIFs(times)[source]#
computeSVPosteriorOnLatentsStats()[source]#
eval()[source]#
evalELLSumAcrossTrialsAndNeurons(svPosteriorOnLatentsStats)[source]#
getIndPointsLocs()[source]#
getKernels()[source]#
getKernelsParams()[source]#
getSVEmbeddingParams()[source]#
getSVPosteriorOnIndPointsParams()[source]#
predictEmbedding(times)[source]#
predictLatents(times)[source]#
sampleCIFs(times, nudget=0.001)[source]#
setELLCalculationParams(eLLCalculationParams)[source]#
setIndPointsLocs(locs)[source]#
setInitialParams(initial_params)[source]#
setKernels(kernels)[source]#
setMeasurements(measurements)[source]#
setParamsAndData(measurements, initial_params, eLLCalculationParams, priorCovRegParam)[source]#

Sets model parameters and data.

Parameters:
  • measurements (nested list) –

    measurements[r][n] are the measurements for trial r and neuron n.

    For a point-process SVLowerBound (i.e., for a SVLowerBound constructed with an expected log-likelihood of class svGPFA.stats.expectedLogLikelihood.PointProcessELL) measurements[r][n] should be a list of spikes times for trial r and neuron n.

    For a Poisson SVLowerBound (i.e., for a SVLowerBound constructed with an expected log-likelihood of class svGPFA.stats.expectedLogLikelihood.PoissonELL) measurements[r][n] should be a tuple of length n_bins containing the spike counts in bins.

  • initial_params (dictionary) – initial parameters as returned by svGPFA.utils.initUtils.getParamsAndKernelsTypes().

  • eLLCalculationParams (dictionary) –

    parameters used to calculate the expected log likelighood.

    For a point-process SVLowerBound eLLCalculationParams should be a dictionary with keys leg_quad_points and leg_quad_points, containing the Legendre quadrature points and weights, respectivey, used to calculate the integral of the expected log likelihood (Eq. 7 in Duncker and Sahani [DS18]).

    For a Poisson SVLowerBound eLLCalculationParams should be a dictionary with key binTimes containing the mean time of every bin.

  • priorCovRegParam (float) – regularization parameter for the prior covariance matrix (\(K_{zz}\) in Eq. 2 of Duncker and Sahani [DS18]).

setPriorCovRegParam(priorCovRegParam)[source]#
class svGPFA.stats.svLowerBound.SVLowerBoundWithParamsGettersAndSetters(eLL, klDiv)[source]#

Bases: SVLowerBound

get_flattened_indPointsLocs()[source]#
get_flattened_indPointsLocs_grad()[source]#
get_flattened_kernels_params()[source]#
get_flattened_kernels_params_grad()[source]#
get_flattened_svEmbedding_params()[source]#
get_flattened_svEmbedding_params_grad()[source]#
get_flattened_svPosteriorOnIndPoints_params()[source]#
get_flattened_svPosteriorOnIndPoints_params_grad()[source]#
set_indPointsLocs_from_flattened(flattened_params)[source]#
set_indPointsLocs_requires_grad(requires_grad)[source]#
set_kernels_params_from_flattened(flattened_params)[source]#
set_kernels_params_requires_grad(requires_grad)[source]#
set_svEmbedding_params_from_flattened(flattened_params)[source]#
set_svEmbedding_params_requires_grad(requires_grad)[source]#
set_svPosteriorOnIndPoints_params_from_flattened(flattened_params)[source]#
set_svPosteriorOnIndPoints_params_requires_grad(requires_grad)[source]#

1.1.3.11. svGPFA.stats.svPosteriorOnIndPoints module#

class svGPFA.stats.svPosteriorOnIndPoints.SVPosteriorOnIndPoints[source]#

Bases: ABC

abstract buildCov()[source]#
abstract getMean()[source]#
abstract getParams()[source]#
abstract setInitialParams(initial_params)[source]#
class svGPFA.stats.svPosteriorOnIndPoints.SVPosteriorOnIndPointsChol[source]#

Bases: SVPosteriorOnIndPoints

buildCov()[source]#
getMean()[source]#
getParams()[source]#
setInitialParams(initial_params)[source]#
class svGPFA.stats.svPosteriorOnIndPoints.SVPosteriorOnIndPointsCholWithGettersAndSetters[source]#

Bases: SVPosteriorOnIndPointsChol

get_flattened_params()[source]#
get_flattened_params_grad()[source]#
set_params_from_flattened(flattened_params)[source]#
set_params_requires_grad(requires_grad)[source]#
class svGPFA.stats.svPosteriorOnIndPoints.SVPosteriorOnIndPointsRank1PlusDiag[source]#

Bases: SVPosteriorOnIndPoints

buildCov()[source]#
getMean()[source]#
getParams()[source]#
setInitialParams(initial_params)[source]#

1.1.3.12. svGPFA.stats.svPosteriorOnLatents module#

class svGPFA.stats.svPosteriorOnLatents.SVPosteriorOnLatents(svPosteriorOnIndPoints, indPointsLocsKMS, indPointsLocsAndTimesKMS)[source]#

Bases: ABC

abstract buildKernelsMatrices()[source]#
abstract computeMeansAndVars()[source]#
getIndPointsLocs()[source]#
getKernels()[source]#
getKernelsParams()[source]#
getSVPosteriorOnIndPointsParams()[source]#
abstract setIndPointsLocs(indPointsLocs)[source]#
abstract setInitialParams(initial_params)[source]#
abstract setKernels()[source]#
setPriorCovRegParam(priorCovRegParam)[source]#
setTimes(times)[source]#
class svGPFA.stats.svPosteriorOnLatents.SVPosteriorOnLatentsAllTimes(svPosteriorOnIndPoints, indPointsLocsKMS, indPointsLocsAndTimesKMS)[source]#

Bases: SVPosteriorOnLatents

buildKernelsMatrices()[source]#
computeMeansAndVars()[source]#
computeMeansAndVarsAtTimes(times)[source]#
predict(times)[source]#
sample(times, nudget=0.001)[source]#
setIndPointsLocs(indPointsLocs)[source]#
setInitialParams(initial_params)[source]#
setKernels(kernels)[source]#
class svGPFA.stats.svPosteriorOnLatents.SVPosteriorOnLatentsAssocTimes(svPosteriorOnIndPoints, indPointsLocsKMS, indPointsLocsAndTimesKMS)[source]#

Bases: SVPosteriorOnLatents

buildKernelsMatrices()[source]#
computeMeansAndVars()[source]#
setIndPointsLocs(indPointsLocs)[source]#
setInitialParams(initial_params)[source]#
setKernels(kernels)[source]#

1.1.3.13. Module contents#