https://github.com/aaltoml/improved-hyperparameter-learning
Codes for 'Improving Hyperparameter Learning under Approximate Inference in Gaussian Process Models' (ICML 2023)
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.6%) to scientific vocabulary
Keywords
Repository
Codes for 'Improving Hyperparameter Learning under Approximate Inference in Gaussian Process Models' (ICML 2023)
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Improving Hyperparameter Learning under Approximate Inference in Gaussian Process Models
This repository is the official implementation of the methods in the publication:
- Rui Li, S.T. John, and Arno Solin (2023). Improving hyperparameter learning under approximate inference in Gaussian process models. In International Conference on Machine Learning (ICML). [arXiv preprint]
The paper aims at improving hyperparameter learning in GP models by focusing on the interplay between variational inference (VI) and the learning target. Instead of using the evidence lower bound (ELBO) both for inferring variational parameters and learning hyperparameters, we show that a direct approximation of the marginal likelihood as in Expectation Propagation (EP) is a better learning objective for hyperparameter optimization.
Example of log marginal likelihood / predictive density surfaces for the ionosphere data set by varying kernel magnitude σ and lengthscale ℓ. The colour scale is the same in all plots (-0.8...0) (normalized by #data). Optimal hyperparameters shown by a black marker. EP and our EP-like marginal likelihood estimation match the MCMC baseline better than VI or LA, thus providing a learning proxy. For prediction, our method still leverages the same variational representation as VI.
The python folder contains the Python experiments code. See the main paper and appendix for details on the baseline methods and the original publications. The reference implementation of our method is based on t-SVGP and the benchmarking setup is built on top of Bayesian benchmarks.
For evaluating (older) baseline methods, the matlab folder contains the Mathworks Matlab code for:
1. MCMC estimation of log marginal likelihood and log predictive density
2. LA and EP implementation for Student-t regression
Environment
Python
We recommend using Python version 3.10.4. To install dependencies:
pip install -r requirement.txt
Alternatively, use Conda to creat a Python virtual environment by
conda env create --file python/env.yaml
Matlab
We used Matlab (The MathWorks, Inc.) R2021a. The code in matlab/contour/ uses the GPML toolbox v. 4.2, and the code in matlab/experiment/ requires the GPstuff toolbox. Check that the toolboxes are included in your path (look for addpath /path/to/gpstuff and addptah path/to/gpml, respectively).
SLURM
We ran our experiments on a SLURM-based compute cluster. The instructions below assume such a SLURM environment, but the experiments can in principle be run sequentially by locally running the submission scripts with the corresponding values of the $SLURM_ARRAY_TASK_ID environment variable set to all values in the (inclusive) range defined by the #SBATCH --array=<start>,<end> line of a submission script.
Our method and example usage
Implementation for our methods are in src folder. We include a 2D classification example in example/classification.ipynb to show how to use our methods for better hyperparameter estimation in GP. We include both the full GP and sparse GP in the example.
Reproduce results in the paper
Figures
Fig. 1 and Fig. 2
To reproduce Fig. 1 and Fig. 2 in the paper:
* Enter the python/experiments/contour-plots folder, activate Python environment in slurm, run
bash
sbatch slurmscript_fig1_python.sh
Enter the
matlab/contour-plotsfolder, activate Matlab environment in slurm, runbash bash run_lml.sh bash run_lp.shWait for all your jobs to finish (for MCMC this could take around 20 hours; you can reduce the runtime in exchange for a noisier surface by reducing the values of
N,Ns,Nb).Go to the
python/experiments/contour-plotsfolder and runbash python collect_mcmc_result.pyGo to the
python/notebooks-for-reproducing-figsfolder, run thereproduce_fig_1_and_fig_2.ipynbnotebook.
Fig. 3
The code for generating this figure relies on the results from Figs. 1 and 2 above. To reproduce Fig. 3 in the paper:
Enter the
python/experiments/sparse-contour-plotsfolder, activate Python environment in slurm, runbash sbatch slurmscript_fig3.shGo to the
python/notebooks-for-reproducing-figsfolder, run thereproduce_fig_3.ipynbnotebook.
Fig. 4
To reproduce Fig. 4 in the paper:
* Enter the python/experiments/classification folder, activate Python environment in slurm, run
bash
bash submit_jobs_table_1.sh
Run
python process_result.pyto collect the resultsGo to the
python/notebooks-for-reproducing-figsfolder, run thereproduce_fig_4.ipynbnotebook
Fig. 5
To reproduce Fig. 5 in the paper:
* Enter the python/experiment/conflict-training-obj folder, activate Python environment in slurm, run
bash
bash submit_jobs_fig5.sh
- Go to the
python/notebooks-for-reproducing-figsfolder, run thereproduce_fig_5.ipynbnotebook.
Tables
Table 1
To reproduce results in Table 1 in the paper:
* For LA, EP, VI and Ours results, enter the python/experiment/classification folder, activate Python environment in slurm, run
bash
bash submit_jobs_table_1.sh
- For MCMC results, enter the
matlab/classificationfolder. We use the same splits as in Python. To generate those splits, you can runpython generate_matlab_data.pyin thepython/experiments/classificationfolder. These have have also been pre-generated and can be downloaded as zipped mat files from Google Drive. Unzip the file and place it under the experiments folder in a new folder nameddata. Then, activate the Matlab environment in slurm and runbash bash submit_mcmc.sh
Table 2
To reproduce results in Table 2 in the paper:
* For VI and Ours results, enter the python/experiments/student-t folder, activate Python environment in slurm, run
bash
bash submit_jobs_table_2.sh
- For LA, EP and MCMC results, enter the
matlab/student-tfolder. Then, activate Matlab environment in slurm, runbash sbatch run_mcmc_student_t.sh
Table 3
To reproduce results in Table 3 in the paper:
* Enter the python/experiment/classification folder, activate Python environment in slurm, run
bash
bash submit_jobs_table_3.sh
License
This software is provided under the MIT license.
Owner
- Name: AaltoML
- Login: AaltoML
- Kind: organization
- Location: Finland
- Website: http://arno.solin.fi
- Repositories: 20
- Profile: https://github.com/AaltoML
Machine learning group at Aalto University lead by Prof. Solin
GitHub Events
Total
Last Year
Dependencies
- bayesnewton =1.3.4
- gpflow ==2.5.1
- gpy ==1.10.10
- numba ==0.57.0
- objax ==1.7.0
- scikit-learn ==1.1.2
- scipy ==1.9.1
- tensorflow ==2.10.0
- tensorflow-probability ==0.18.0