Package: gpcm
GPCMImplementation of the GPCM and variationsCitation:@inproceedings{Bruinsma:2022:Modelling_Non-Smooth_Signals_With_Complex,
    title = {Modelling Non-Smooth Signals With Complex Spectral Structure},
    year = {2022},
    author = {Wessel P. Bruinsma and Martin Tegn{\' e}r and Richard E. Turner},
    booktitle = {Proceedings of the 25th International Conference on Artificial Intelligence and Statistics},
    series = {Proceedings of Machine Learning Research},
    publisher = {PMLR},
    eprint = {https://arxiv.org/abs/2203.06997},
}Contents:InstallationExampleAvailable Models and Inference SchemesMaking PredictionsSample ExperimentsReproduce Experiments From the PaperInstallationSeethe instructions here.
Then simplypip install gpcmIf you have a GPU available, it is recommended that you use a GPU-accelerated version
of JAX.ExampleimportnumpyasnpfromgpcmimportRGPCMmodel=RGPCM(window=2,scale=1,n_u=30,t=(0,10))# Sample from the prior.t=np.linspace(0,10,100)K,y=model.sample(t)# Sampled kernel matrix and sampled noisy function# Fit model to the sample.model.fit(t,y)# Compute the ELBO.print(model.elbo(t,y))# Make predictions.posterior=model.condition(t,y)mean,var=posterior.predict(t)Available Models and Approximation SchemesThe following models are available:ModelDescriptionGPCMWhite noise excitation with a smooth filterCGPCMWhite noise excitation with a smooth causal filterRGPCMOrnstein-Uhlenbeck excitation with a white noise filterThe simplest way of constructing a model is to set the following keywords:KeywordDescriptionwindowLargest length scale of signalscaleSmallest length scale of signaltSome iterable containing the limits of the inputs of interestExample:fromgpcmimportRGPCMmodel=RGPCM(window=4,scale=0.5,t=(0,10))Please see the API for a detailed description of the keyword arguments which you can
set.
Amongst these keyword arguments, we highlight the following few which are important:Optional KeywordDescriptionn_uNumber of inducing points for the filtern_z(GPCMandCGPCM)Number of inducing points for the excitation signalm_max(RGPCM)Half of the number of variational Fourier features. Set ton_z // 2for equal computational expense.tSome iterable containing the limits of the inputs of interestThe constructors of these models also take in a keywordscheme, which can be
set  to one of the following values:schemeDescription"structured"(default)Structured approximation. Recommended."mean-field-ca"Mean-field approximation learned by coordinate ascent. This does not learn hyperparameters."mean-field-gradient"Mean-field approximation learned by gradient-based optimisation"mean-field-collapsed-gradient"Collapsed mean-field approximation learned by gradient-based optimisationExample:fromgpcmimportRGPCMmodel=RGPCM(scheme="mean-field-ca",window=4,scale=0.5,t=(0,10))Making Predictions With a ModelThe implemented models follow the interface fromProbMods.To begin with, construct a model:fromgpcmimportGPCMmodel=GPCM(window=4,scale=0.5,t=(0,10))Sample From the PaperSampling gives back the sampled kernel matrix and the noisy outputs.K,y=model.sample(t)Fit the Model to DataIt is recommended that you normalise the data before fitting.
It is also recommended that you do not fit the more to more than 1000 data points.model.fit(t,y)The functionfittakes in the keyword argumentiters.
The rule of thumb which you can use is as follows:itersDescription5_000(default)Reasonable fit10_000Better fit20_000Good fit30_000Pretty good fitThe functionfitalso takes in the keyword argumentrate.
The rule of thumb which you can use here is as follows:rateDescription5e-2(default)Fast learning2e-2Slower, but more stable learning5e-3Slow learningCompute the ELBOIt is recommended that you normalise the data before computing the ELBO.
It is also recommended that you do not compute the ELBO for more than 1000 data points.elbo=model.elbo(t,y)Condition the Model on DataIt is recommended that you normalise the data before conditioning and unnormalise
the predictions.
It is also recommended that you do not condition on more than 1000 data points.posterior_model=model.condition(t,y)Make PredictionsPredictions for new inputs:mean,var=posterior_model.predict(t_new)Predictions for the kernel:pred=posterior_model.predict_kernel()x,mean,var=pred.x,pred.mean,pred.varPredictions for the PSD:pred=posterior_model.predict_psd()x,mean,var=pred.x,pred.mean,pred.varSample ExperimentsLearn a GP With a Known Kernelpythonexperiments/eq.pypythonexperiments/smk.pyLearn the Mauna Loa CO2 Data Setpythonexperiments/mauna_loa.pyReproduce Experiments From the PaperSeehere.