{"id":22583012,"url":"https://github.com/andrewwango/gpr-mcmc","last_synced_at":"2025-03-28T16:45:19.158Z","repository":{"id":185025931,"uuid":"443593101","full_name":"Andrewwango/gpr-mcmc","owner":"Andrewwango","description":"Gaussian Process Regression (GPR) with non-Gaussian likelihoods using robust infinite-dimension Monte Carlo Markov Chain (MCMC) sampling for spatial inference problems","archived":false,"fork":false,"pushed_at":"2023-09-07T13:48:08.000Z","size":2544,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-02T17:30:17.204Z","etag":null,"topics":["gaussian-process-regression","gaussian-processes","mcmc","monte-carlo-markov-chain","preconditioned-crank-nicholson","spatial-interpolation","spatial-regression"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Andrewwango.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-01T17:53:36.000Z","updated_at":"2025-02-01T15:09:28.000Z","dependencies_parsed_at":"2023-07-31T12:33:14.377Z","dependency_job_id":"9db5e86e-9986-4898-bba2-98eb4a4436ba","html_url":"https://github.com/Andrewwango/gpr-mcmc","commit_stats":null,"previous_names":["andrewwango/gpr-mcmc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrewwango%2Fgpr-mcmc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrewwango%2Fgpr-mcmc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrewwango%2Fgpr-mcmc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrewwango%2Fgpr-mcmc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Andrewwango","download_url":"https://codeload.github.com/Andrewwango/gpr-mcmc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246068269,"owners_count":20718501,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gaussian-process-regression","gaussian-processes","mcmc","monte-carlo-markov-chain","preconditioned-crank-nicholson","spatial-interpolation","spatial-regression"],"created_at":"2024-12-08T06:13:13.775Z","updated_at":"2025-03-28T16:45:18.788Z","avatar_url":"https://github.com/Andrewwango.png","language":"Jupyter Notebook","readme":"# Gaussian Process Regression using Monte Carlo Markov Chain sampling\nGaussian Process Regression (GPR) with non-Gaussian likelihoods using robust infinite-dimension Monte Carlo Markov Chain (MCMC) sampling.\n\n## Why?\nGaussian Process Regression is only available in exact, closed form when the data likelihood is assumed to be Gaussian. However, in many use-cases data can be:\n\n- Discrete count data (such as population), in which case the most appropriate likelihood is Poisson;\n- Binary classification data, in which case an appropriate likelihood could be the probit model.\n\nTo deal with this, there are a number of approximation methods, such as the Laplace approximation. See [[Murphy: Probabilistic Machine Learning: Advanced Topics](https://probml.github.io/pml-book/book2.html) (Section 18.4)] for an excellent treatment. The `scikit-learn` [GP classification](https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.GaussianProcessClassifier.html#sklearn.gaussian_process.GaussianProcessClassifier) uses the Laplace method.\n\nThe MCMC sampling approach is attractive as we can theoretically sample from any non-conjugate likelihood to simulate an exact solution. This works using a Metropolis-Hastings style accept/reject step informed by the given likelihood.\n\nHowever, the performance of traditional Metropolis-Hastings suffers in high dimensions such as in spatial problems where there are many data points, because the acceptance probability in the Metropolis step degenerates to zero. In this repo we implement MCMC using the [preconditioned Crank-Nicholson proposal step](https://en.wikipedia.org/wiki/Preconditioned_Crank%E2%80%93Nicolson_algorithm), which is well-defined in infinite dimensions.\n\n## Usage\n\nUse the algorithm as you would normally use `scikit-learn` [Gaussian Process regression](sklearn.gaussian_process.GaussianProcessRegressor) or [classification](https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.GaussianProcessClassifier.html#sklearn.gaussian_process.GaussianProcessClassifier):\n\n```python\n\u003e\u003e\u003e import numpy as np\n\u003e\u003e\u003e from gpr_mcmc import GaussianProcessMCMCRegressor as GPMR\n\u003e\u003e\u003e gpmr = GPMR(\n    ell=0.2, # default RBF kernel length\n    log_likelihood='poisson',\n    random_state=np.random.default_rng(42) # seed for MCMC sampling\n    )\n\u003e\u003e\u003e gpmr.fit(X_train, y_train)\ngpr_mcmc.gpr_mcmc.GaussianProcessMCMCRegressor\n\u003e\u003e\u003e gpmr.score(X_test, y_test, method=\"mae\") # mean absolute error\n```\n\nSee [demo.ipynb](demo.ipynb) for a real example using spatial data.\n### Main options\n\n- `mcmc_method`: MCMC variant to use. \"grw\" is Gaussian random walk - Metropolis-Hastings with a Gaussian prior proposal. \"pcn\" is preconditioned Crank-Nicholson which does not degenerate in infinite-dimensions.\n- `log_likelihood`: If str, must be one of `poisson`, `gaussian` or `probit`. If a callable, see [likelihoods.py](likelihoods.py) for example implementations.\n- `kernel`: Any GPR kernel from `scikit-learn` [Kernel API](https://scikit-learn.org/stable/modules/gaussian_process.html#kernels-for-gaussian-processes). If None, RBF kernel is used with ell given by `ell`.\n- `beta`: step size using in MCMC proposals. Controls the \"temperature\" of the sampling.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewwango%2Fgpr-mcmc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewwango%2Fgpr-mcmc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewwango%2Fgpr-mcmc/lists"}