{"id":19469804,"url":"https://github.com/plugyawn/gp-zoo","last_synced_at":"2025-04-15T06:20:33.538Z","repository":{"id":68273066,"uuid":"567928594","full_name":"plugyawn/gp-zoo","owner":"plugyawn","description":"A repository with implementations of major papers on Gaussian Process regression models, implemented from scratch in Python, notably including Stochastic Variational Gaussian Processes.","archived":false,"fork":false,"pushed_at":"2022-11-19T21:13:37.000Z","size":59114,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T17:01:45.325Z","etag":null,"topics":["bayesian-inference","gaussian-processes","machine-learning","probabilistic-programming","research-paper"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plugyawn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-11-18T23:24:13.000Z","updated_at":"2024-05-22T07:03:34.000Z","dependencies_parsed_at":"2023-05-28T21:30:44.561Z","dependency_job_id":null,"html_url":"https://github.com/plugyawn/gp-zoo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plugyawn%2Fgp-zoo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plugyawn%2Fgp-zoo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plugyawn%2Fgp-zoo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plugyawn%2Fgp-zoo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plugyawn","download_url":"https://codeload.github.com/plugyawn/gp-zoo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249017188,"owners_count":21198924,"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":["bayesian-inference","gaussian-processes","machine-learning","probabilistic-programming","research-paper"],"created_at":"2024-11-10T18:54:08.593Z","updated_at":"2025-04-15T06:20:33.523Z","avatar_url":"https://github.com/plugyawn.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![forthebadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/)\n[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)\n\n\n\n\u003cdiv align = center\u003e\n\u003ca href = \"github.com/plugyawn\"\u003e\u003cimg width=\"300px\" height=\"300px\" src= \"https://user-images.githubusercontent.com/76529011/202820671-44b1d06e-1d92-4585-b2d8-f3e18fad50cb.png\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n-----------------------------------------\n[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)![Compatibility](https://img.shields.io/badge/compatible%20with-python3.6.x-blue.svg)\n\n```GP-Zoo``` is a collection of implementations of significant papers on Gaussian Processes with readable, simple code, over the past decade; ranging from Sparse Gaussian Process Regression from Titsias, 2009, to Stochastic Variational Gaussian Processes for classification and regression, by Hensman, 2014. \n\n# Implementations\n\nWe start with the standard ```GPJax``` dataset for regression.\n```python\n\nimport jax.random as jr\nkey = jax.random.PRNGKey(0)\nn = 1000\nnoise = 0.2\n\nx = jr.uniform(key=key, minval=-5.0, maxval=5.0,\n               shape=(n,)).sort().reshape(-1, 1)\n\n\ndef f(x): return jnp.sin(4 * x) + jnp.cos(2 * x)\n\n\nsignal = f(x)\ny = signal + jr.normal(key, shape=signal.shape) * noise\n\nxtest = jnp.linspace(-5.5, 5.5, 500).reshape(-1, 1)\n\nz = jnp.linspace(-5.0, 5.0, 50).reshape(-1, 1)\n\nfig, ax = plt.subplots(figsize=(12, 5))\nax.plot(x, y, \"o\", alpha=0.3, label=\"Samples\")\nax.plot(xtest, f(xtest), label=\"True function\")\n[ax.axvline(x=z_i, color=\"black\", alpha=0.3, linewidth=1) for z_i in z]\nplt.show()\n```\n![image](https://user-images.githubusercontent.com/76529011/202865518-e7ee8de9-7b8a-4f70-b883-55fc3b68a3a7.png)\n\n```GP-Zoo```'s regression implementations are all based on this dataset, although it can be easily switched out by replacing ```x``` and ```y``` with a different dataset.\nFor example, Stochastic Variational Gaussian Processes for Classification (*Hensman et al, 2014*), classifies the ```moons``` dataset:\n```python\nn_samples = 100\nnoise = 0.1\nrandom_state = 0\nshuffle = True\n\nX, y = make_moons(\n    n_samples=n_samples, random_state=random_state, noise=noise, shuffle=shuffle\n)\nX = StandardScaler().fit_transform(X)  # Yes, this is useful for GPs\n\nX, y = map(jnp.array, (X, y))\n\nplt.scatter(X[:, 0], X[:, 1], c=y)\n```\n![image](https://user-images.githubusercontent.com/76529011/202865498-775da1e2-de64-4bd9-af97-f578cc0aa639.png)\n\n# Examples of regression implementations\n\n## Stochastic Variational Gaussian Process\nA parallelizable, scalable algorithm for Gaussian Processes, optimized for dealing with big data. Crosses are inducing points, while translucent blue dots are the original full dataset.\n\n![image](https://user-images.githubusercontent.com/76529011/202865852-698638d7-c08b-4afb-99cf-cb7e3ec9bf94.png)\n\n## Sparse Gaussian Process\n\nBased on the same dataset, a sparse Gaussian Process would include:\n![image](https://user-images.githubusercontent.com/76529011/202865600-7f74d040-dcfd-4be2-8ad4-06d69454cc8d.png)\n\n## Titsias's Sparse Gaussian Process\n\nBased on Titsias et al (2009), the greedy-algorithm for selecting inducing points leads to a good approximation of an exact Gaussian Process.\n![image](https://user-images.githubusercontent.com/76529011/202865698-503ff319-5c21-48ca-8aad-68b90943d40c.png)\n\n## Variational training of Inducing points\n\nA technique based on minimzing the Evidence Lower Bound as a loss for how well the inducing points approximate the full dataset.\n![image](https://user-images.githubusercontent.com/76529011/202865728-c0570d98-f666-4f49-8883-69c615ad8587.png)\n\n\n\n# Contributing\n\nGP-Zoo is a work-in-progress, so feel free to put in a PR and share in the work!\n\nNotably, if you can find a way to add backtesting strategies through boolean expressions passed to the function, that would be really helpful!\nReach me at ```progyan.das@iitgn.ac.in``` or ```progyan.me```.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplugyawn%2Fgp-zoo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplugyawn%2Fgp-zoo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplugyawn%2Fgp-zoo/lists"}