# **UncertaintyPlayground**

[](https://www.python.org/downloads/)
[](https://pypi.org/project/UncertaintyPlayground/)
[](LICENSE)
## Installation
*Requirements*:
- Python >= 3.8
- PyTorch == 2.0.1
- GPyTorch == 1.10
- Numpy == 1.24.0
- Seaborn == 0.12.2
Use `PyPI` to install the package:
```bash
pip install uncertaintyplayground
```
or alterntively, to use the development version, install directly from GitHub:
```bash
pip install git+https://github.com/unco3892/UncertaintyPlayground.git
```
## Usage
You can train and visualize the results of the models in the following way (this example uses the [California Housing dataset from Sklearn](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.fetch_california_housing.html)):
```python
from uncertaintyplayground.trainers.svgp_trainer import SparseGPTrainer
from uncertaintyplayground.trainers.mdn_trainer import MDNTrainer
from uncertaintyplayground.predplot.svgp_predplot import compare_distributions_svgpr
from uncertaintyplayground.predplot.mdn_predplot import compare_distributions_mdn
from uncertaintyplayground.predplot.grid_predplot import plot_results_grid
import torch
import numpy as np
from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
# Load the California Housing dataset
california = fetch_california_housing()
# Convert X and y to numpy arrays of float32
X = np.array(california.data, dtype=np.float32)
y = np.array(california.target, dtype=np.float32)
# Set random seed for reproducibility
np.random.seed(42)
torch.manual_seed(1)
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# SVGPR: Initialize and train a SVGPR model with 100 inducing points
california_trainer_svgp = SparseGPTrainer(X_train, y_train, num_inducing_points=100, num_epochs=30, batch_size=512, lr=0.1, patience=3)
california_trainer_svgp.train()
# MDN: Initialize and train an MDN model
california_trainer_mdn = MDNTrainer(X_train, y_train, num_epochs=100, lr=0.001, dense1_units=50, n_gaussians=10)
california_trainer_mdn.train()
# SVPGR: Visualize the SVGPR's predictions for multiple instances
plot_results_grid(trainer=california_trainer_svgp, compare_func=compare_distributions_svgpr, X_test=X_test, Y_test=y_test, indices=[900, 500], ncols=2)
# MDN: Visualize the MDN's predictions for multiple instances
plot_results_grid(trainer=california_trainer_mdn, compare_func=compare_distributions_mdn, X_test=X_test, Y_test=y_test, indices=[900, 500], ncols=2)
```
You can find another example for MDN in the `examples` folder.
<!-- ## Examples, Tutorials, and Documentation -->
## Contributors
This library is maintained by [Ilia Azizi](https://iliaazizi.com/) (University of Lausanne). Any other contributors are welcome to join! Feel free to get in touch with (contact links on my website).
<!-- Please see the [contributing guide](CONTRIBUTING.md) for more details. -->
## Citation
If you use this package in your research, please cite our work:
**UncertaintyPlayground: A Fast and Simplified Python Library for Uncertainty Estimation** , Ilia Azizi, [arXiv:2310.15281](https://arxiv.org/abs/2310.15281)
```bibtex
@misc{azizi2023uncertaintyplayground,
title={UncertaintyPlayground: A Fast and Simplified Python Library for Uncertainty Estimation},
author={Ilia Azizi},
year={2023},
eprint={2310.15281},
archivePrefix={arXiv},
primaryClass={stat.ML}
}
```
## License
Please see the project MIT licensed [here](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/Unco3892/UncertaintyPlayground",
"name": "UncertaintyPlayground",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Ilia Azizi",
"author_email": "ilia.azizi@unil.ch",
"download_url": "https://files.pythonhosted.org/packages/3a/ec/1797423e5eb491cdc002620b63f6506f8518331bde726c43912f19077e6e/UncertaintyPlayground-0.1.2.tar.gz",
"platform": null,
"description": "# **UncertaintyPlayground**\n\n\n[](https://www.python.org/downloads/)\n[](https://pypi.org/project/UncertaintyPlayground/)\n[](LICENSE)\n\n## Installation\n\n*Requirements*:\n- Python >= 3.8\n- PyTorch == 2.0.1\n- GPyTorch == 1.10\n- Numpy == 1.24.0\n- Seaborn == 0.12.2\n\nUse `PyPI` to install the package:\n```bash\npip install uncertaintyplayground\n```\n\nor alterntively, to use the development version, install directly from GitHub:\n```bash\npip install git+https://github.com/unco3892/UncertaintyPlayground.git\n```\n\n## Usage\n\nYou can train and visualize the results of the models in the following way (this example uses the [California Housing dataset from Sklearn](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.fetch_california_housing.html)):\n\n```python\nfrom uncertaintyplayground.trainers.svgp_trainer import SparseGPTrainer\nfrom uncertaintyplayground.trainers.mdn_trainer import MDNTrainer\nfrom uncertaintyplayground.predplot.svgp_predplot import compare_distributions_svgpr\nfrom uncertaintyplayground.predplot.mdn_predplot import compare_distributions_mdn\nfrom uncertaintyplayground.predplot.grid_predplot import plot_results_grid\nimport torch\nimport numpy as np\nfrom sklearn.datasets import fetch_california_housing\nfrom sklearn.model_selection import train_test_split\n\n# Load the California Housing dataset\ncalifornia = fetch_california_housing()\n\n# Convert X and y to numpy arrays of float32\nX = np.array(california.data, dtype=np.float32)\ny = np.array(california.target, dtype=np.float32)\n\n# Set random seed for reproducibility\nnp.random.seed(42)\ntorch.manual_seed(1)\n\n# Split the dataset into training and testing sets\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n\n# SVGPR: Initialize and train a SVGPR model with 100 inducing points\ncalifornia_trainer_svgp = SparseGPTrainer(X_train, y_train, num_inducing_points=100, num_epochs=30, batch_size=512, lr=0.1, patience=3)\ncalifornia_trainer_svgp.train()\n\n# MDN: Initialize and train an MDN model\ncalifornia_trainer_mdn = MDNTrainer(X_train, y_train, num_epochs=100, lr=0.001, dense1_units=50, n_gaussians=10)\ncalifornia_trainer_mdn.train()\n\n# SVPGR: Visualize the SVGPR's predictions for multiple instances\nplot_results_grid(trainer=california_trainer_svgp, compare_func=compare_distributions_svgpr, X_test=X_test, Y_test=y_test, indices=[900, 500], ncols=2)\n\n# MDN: Visualize the MDN's predictions for multiple instances\nplot_results_grid(trainer=california_trainer_mdn, compare_func=compare_distributions_mdn, X_test=X_test, Y_test=y_test, indices=[900, 500], ncols=2)\n```\n\nYou can find another example for MDN in the `examples` folder.\n\n<!-- ## Examples, Tutorials, and Documentation -->\n\n## Contributors\n\nThis library is maintained by [Ilia Azizi](https://iliaazizi.com/) (University of Lausanne). Any other contributors are welcome to join! Feel free to get in touch with (contact links on my website).\n<!-- Please see the [contributing guide](CONTRIBUTING.md) for more details. -->\n\n## Citation\n\nIf you use this package in your research, please cite our work:\n\n**UncertaintyPlayground: A Fast and Simplified Python Library for Uncertainty Estimation** , Ilia Azizi, [arXiv:2310.15281](https://arxiv.org/abs/2310.15281)\n\n```bibtex\n@misc{azizi2023uncertaintyplayground,\n title={UncertaintyPlayground: A Fast and Simplified Python Library for Uncertainty Estimation}, \n author={Ilia Azizi},\n year={2023},\n eprint={2310.15281},\n archivePrefix={arXiv},\n primaryClass={stat.ML}\n}\n```\n\n## License\n\nPlease see the project MIT licensed [here](LICENSE).\n",
"bugtrack_url": null,
"license": "",
"summary": "A Python library for uncertainty estimation in supervised learning tasks",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/Unco3892/UncertaintyPlayground"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a230ba47df7a21f0aa7d930e6163a8c7fc0173753f847091997b32aeda992612",
"md5": "65eb539bcb74f91e42c902bfe8bd1bc0",
"sha256": "8d07e365c9806af72dc1bfd9e5e536230cb7804a8b0e3ab405db5bb3e4f3513b"
},
"downloads": -1,
"filename": "UncertaintyPlayground-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "65eb539bcb74f91e42c902bfe8bd1bc0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 26391,
"upload_time": "2023-10-25T18:35:10",
"upload_time_iso_8601": "2023-10-25T18:35:10.884993Z",
"url": "https://files.pythonhosted.org/packages/a2/30/ba47df7a21f0aa7d930e6163a8c7fc0173753f847091997b32aeda992612/UncertaintyPlayground-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3aec1797423e5eb491cdc002620b63f6506f8518331bde726c43912f19077e6e",
"md5": "a6255adf049c73b35acf9b71d9c7cdba",
"sha256": "78dbd102e83d3e8a37c4e392a5bbbf2516bfa1113aa6bc88288b5f6ae801882d"
},
"downloads": -1,
"filename": "UncertaintyPlayground-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "a6255adf049c73b35acf9b71d9c7cdba",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16538,
"upload_time": "2023-10-25T18:35:12",
"upload_time_iso_8601": "2023-10-25T18:35:12.666525Z",
"url": "https://files.pythonhosted.org/packages/3a/ec/1797423e5eb491cdc002620b63f6506f8518331bde726c43912f19077e6e/UncertaintyPlayground-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-25 18:35:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Unco3892",
"github_project": "UncertaintyPlayground",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "uncertaintyplayground"
}