----
This project has now been incorporated into [GPJax](https://github.com/JaxGaussianProcesses/GPJax).
----
# [JaxUtils](https://github.com/JaxGaussianProcesses/JaxUtils)
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/JaxGaussianProcesses/JaxUtils/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/JaxGaussianProcesses/JaxUtils/tree/master)
`JaxUtils` provides utility functions for the [`JaxGaussianProcesses`]() ecosystem.</h2>
# Contents
- [PyTree](#pytree)
- [Dataset](#dataset)
# PyTree
## Overview
`jaxutils.PyTree` is a mixin class for [registering a python class as a JAX PyTree](https://jax.readthedocs.io/en/latest/pytrees.html#extending-pytrees). You would define your Python class as follows.
```python
class MyClass(jaxutils.PyTree):
...
```
## Example
```python
import jaxutils
from jaxtyping import Float, Array
class Line(jaxutils.PyTree):
def __init__(self, gradient: Float[Array, "1"], intercept: Float[Array, "1"]) -> None
self.gradient = gradient
self.intercept = intercept
def y(self, x: Float[Array, "N"]) -> Float[Array, "N"]
return x * self.gradient + self.intercept
```
# Dataset
## Overview
`jaxutils.Dataset` is a datset abstraction. In future, we wish to extend this to a heterotopic and isotopic data abstraction.
## Example
```python
import jaxutils
import jax.numpy as jnp
# Inputs
X = jnp.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
# Outputs
y = jnp.array([[7.0], [8.0], [9.0]])
# Datset
D = jaxutils.Dataset(X=X, y=y)
print(f'The number of datapoints is {D.n}')
print(f'The input dimension is {D.in_dim}')
print(f'The output dimension is {D.out_dim}')
print(f'The input data is {D.X}')
print(f'The output data is {D.y}')
print(f'The data is supervised {D.is_supervised()}')
print(f'The data is unsupervised {D.is_unsupervised()}')
```
```
The number of datapoints is 3
The input dimension is 2
The output dimension is 1
The input data is [[1. 2.]
[3. 4.]
[5. 6.]]
The output data is [[7.]
[8.]
[9.]]
The data is supervised True
The data is unsupervised False
```
You can also add dataset together to concatenate them.
```python
# New inputs
X_new = jnp.array([[1.5, 2.5], [3.5, 4.5], [5.5, 6.5]])
# New outputs
y_new = jnp.array([[7.0], [8.0], [9.0]])
# New dataset
D_new = jaxutils.Dataset(X=X_new, y=y_new)
# Concatenate the two datasets
D = D + D_new
print(f'The number of datapoints is {D.n}')
print(f'The input dimension is {D.in_dim}')
print(f'The output dimension is {D.out_dim}')
print(f'The input data is {D.X}')
print(f'The output data is {D.y}')
print(f'The data is supervised {D.is_supervised()}')
print(f'The data is unsupervised {D.is_unsupervised()}')
```
```
The number of datapoints is 6
The input dimension is 2
The output dimension is 1
The input data is [[1. 2. ]
[3. 4. ]
[5. 6. ]
[1.5 2.5]
[3.5 4.5]
[5.5 6.5]]
The output data is [[7.]
[8.]
[9.]
[7.]
[8.]
[9.]]
The data is supervised True
The data is unsupervised False
```
Raw data
{
"_id": null,
"home_page": null,
"name": "jaxutils-nightly",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "gaussian-processes jax machine-learning bayesian",
"author": "Daniel Dodd and Thomas Pinder",
"author_email": "tompinder@live.co.uk",
"download_url": "https://files.pythonhosted.org/packages/98/78/7645cf24c869d733b7a0b089f4d3225a7d1f3b29c929c93ae8bf5a99f8c8/jaxutils-nightly-0.0.8.dev20241009.tar.gz",
"platform": null,
"description": "----\nThis project has now been incorporated into [GPJax](https://github.com/JaxGaussianProcesses/GPJax).\n----\n# [JaxUtils](https://github.com/JaxGaussianProcesses/JaxUtils)\n\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/JaxGaussianProcesses/JaxUtils/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/JaxGaussianProcesses/JaxUtils/tree/master)\n\n`JaxUtils` provides utility functions for the [`JaxGaussianProcesses`]() ecosystem.</h2>\n\n# Contents\n\n- [PyTree](#pytree)\n- [Dataset](#dataset)\n\n# PyTree\n\n## Overview\n\n`jaxutils.PyTree` is a mixin class for [registering a python class as a JAX PyTree](https://jax.readthedocs.io/en/latest/pytrees.html#extending-pytrees). You would define your Python class as follows.\n\n```python\nclass MyClass(jaxutils.PyTree):\n ...\n\n```\n\n## Example\n\n```python\nimport jaxutils\n\nfrom jaxtyping import Float, Array\n\nclass Line(jaxutils.PyTree):\n def __init__(self, gradient: Float[Array, \"1\"], intercept: Float[Array, \"1\"]) -> None\n self.gradient = gradient\n self.intercept = intercept\n\n def y(self, x: Float[Array, \"N\"]) -> Float[Array, \"N\"]\n return x * self.gradient + self.intercept\n```\n\n# Dataset\n\n## Overview\n\n`jaxutils.Dataset` is a datset abstraction. In future, we wish to extend this to a heterotopic and isotopic data abstraction.\n\n## Example\n\n```python\nimport jaxutils\nimport jax.numpy as jnp\n\n# Inputs\nX = jnp.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])\n\n# Outputs\ny = jnp.array([[7.0], [8.0], [9.0]])\n\n# Datset\nD = jaxutils.Dataset(X=X, y=y)\n\nprint(f'The number of datapoints is {D.n}')\nprint(f'The input dimension is {D.in_dim}')\nprint(f'The output dimension is {D.out_dim}')\nprint(f'The input data is {D.X}')\nprint(f'The output data is {D.y}')\nprint(f'The data is supervised {D.is_supervised()}')\nprint(f'The data is unsupervised {D.is_unsupervised()}')\n```\n\n```\nThe number of datapoints is 3\nThe input dimension is 2\nThe output dimension is 1\nThe input data is [[1. 2.]\n [3. 4.]\n [5. 6.]]\nThe output data is [[7.]\n [8.]\n [9.]]\nThe data is supervised True\nThe data is unsupervised False\n```\n\nYou can also add dataset together to concatenate them.\n\n```python\n# New inputs\nX_new = jnp.array([[1.5, 2.5], [3.5, 4.5], [5.5, 6.5]])\n\n# New outputs\ny_new = jnp.array([[7.0], [8.0], [9.0]])\n\n# New dataset\nD_new = jaxutils.Dataset(X=X_new, y=y_new)\n\n# Concatenate the two datasets\nD = D + D_new\n\nprint(f'The number of datapoints is {D.n}')\nprint(f'The input dimension is {D.in_dim}')\nprint(f'The output dimension is {D.out_dim}')\nprint(f'The input data is {D.X}')\nprint(f'The output data is {D.y}')\nprint(f'The data is supervised {D.is_supervised()}')\nprint(f'The data is unsupervised {D.is_unsupervised()}')\n```\n\n```\nThe number of datapoints is 6\nThe input dimension is 2\nThe output dimension is 1\nThe input data is [[1. 2. ]\n [3. 4. ]\n [5. 6. ]\n [1.5 2.5]\n [3.5 4.5]\n [5.5 6.5]]\nThe output data is [[7.]\n [8.]\n [9.]\n [7.]\n [8.]\n [9.]]\nThe data is supervised True\nThe data is unsupervised False\n```\n\n\n",
"bugtrack_url": null,
"license": "LICENSE",
"summary": "Utility functions for JaxGaussianProcesses",
"version": "0.0.8.dev20241009",
"project_urls": {
"Documentation": "https://JaxUitls.readthedocs.io/en/latest/",
"Source": "https://github.com/JaxGaussianProcesses/JaxUitls"
},
"split_keywords": [
"gaussian-processes",
"jax",
"machine-learning",
"bayesian"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8ead4d51ce10c6bfc1834f947a812b5269249f3524ca9e9bbe51e9413b3a8c84",
"md5": "4ad078d5bb344171c5cd0c3397ef960f",
"sha256": "df28a2c7cb9210fbc4fbbdc5e32baae873582c99fcb18816ccef2591fcc45d8a"
},
"downloads": -1,
"filename": "jaxutils_nightly-0.0.8.dev20241009-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4ad078d5bb344171c5cd0c3397ef960f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17977,
"upload_time": "2024-10-09T00:06:35",
"upload_time_iso_8601": "2024-10-09T00:06:35.745891Z",
"url": "https://files.pythonhosted.org/packages/8e/ad/4d51ce10c6bfc1834f947a812b5269249f3524ca9e9bbe51e9413b3a8c84/jaxutils_nightly-0.0.8.dev20241009-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "98787645cf24c869d733b7a0b089f4d3225a7d1f3b29c929c93ae8bf5a99f8c8",
"md5": "8cd51492da178aa9effc7c4045f2d6fc",
"sha256": "a5cd5f4a6b314bc851aae9670a1f314ebc4bec3e0e089e680df8c9bd60e3735e"
},
"downloads": -1,
"filename": "jaxutils-nightly-0.0.8.dev20241009.tar.gz",
"has_sig": false,
"md5_digest": "8cd51492da178aa9effc7c4045f2d6fc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 30159,
"upload_time": "2024-10-09T00:06:37",
"upload_time_iso_8601": "2024-10-09T00:06:37.700073Z",
"url": "https://files.pythonhosted.org/packages/98/78/7645cf24c869d733b7a0b089f4d3225a7d1f3b29c929c93ae8bf5a99f8c8/jaxutils-nightly-0.0.8.dev20241009.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-09 00:06:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "JaxGaussianProcesses",
"github_project": "JaxUitls",
"github_not_found": true,
"lcname": "jaxutils-nightly"
}