Name | heare-histograms JSON |
Version |
0.1.3
JSON |
| download |
home_page | None |
Summary | Pure python histogram implementation for analysis and prediction. |
upload_time | 2024-05-30 00:34:11 |
maintainer | None |
docs_url | None |
author | Sean Fitzgerald |
requires_python | <4.0,>=3.11 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Heare Histograms Library
This library provides two main classes: Histogram and Group. The Histogram class is a generic data structure for storing and sampling data points, while the Group class represents a collection of Histogram instances or other Group instances.
Groups can be used to generate synthetic composite histograms.
# Installation
To install the library, you can use pip:
```sh
pip install heare-histograms
```
# Usage
## Histogram
The Histogram class can be imported and used as follows:
```python
from heare.histograms import Histogram, Shift, Scale, Max
# Create a new histogram
hist = Histogram[int](max_size=1000)
# Observe data points
hist.observe([1, 2, 3, 4, 5])
# Sample a data point
sample = hist.sample()
# Get the value at a given percentile
percentile_val = hist.percentile(0.9)
# Combine two histograms
hist2 = Histogram[int](data=[10, 20, 30])
combined = hist + hist2
# Apply transformations to the histogram
shifted_hist = Shift(hist, 10)
scaled_hist = Scale(hist, 2.0)
capped_hist = Max(hist, 100)
```
The Histogram class supports various operations, such as observing new data points, sampling, computing percentiles, combining histograms, and applying transformations like shifting, scaling, and capping values.
# Group
The Group class can be imported and used as follows:
```python
from heare.histograms import Histogram, Group
# Create a new group with two histograms
hist1 = Histogram[int](data=[1, 2, 3])
hist2 = Histogram[int](data=[10, 20, 30])
group = Group[int]([("hist1", hist1), ("hist2", hist2)])
# Sample a value from the group
sample = group.sample()
# Explain the sampled value
explanation = group.explain_sample()
```
The Group class allows you to combine multiple Histogram instances or other Group instances into a single entity. You can sample values from the group and obtain an explanation of the sampled value, breaking it down into contributions from each element.
# Contributing
Contributions to the library are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/heare-io/heare-histograms).
# License
This library is released under the [MIT License](https://opensource.org/license/mit).
Raw data
{
"_id": null,
"home_page": null,
"name": "heare-histograms",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": null,
"author": "Sean Fitzgerald",
"author_email": "sean@fitzgeralds.me",
"download_url": "https://files.pythonhosted.org/packages/5e/fd/b4c48a70dcb6ece91e6e32aaa4649fb6385134a2c35624ab82636b3a6f2e/heare_histograms-0.1.3.tar.gz",
"platform": null,
"description": "# Heare Histograms Library\nThis library provides two main classes: Histogram and Group. The Histogram class is a generic data structure for storing and sampling data points, while the Group class represents a collection of Histogram instances or other Group instances. \nGroups can be used to generate synthetic composite histograms. \n\n# Installation\nTo install the library, you can use pip:\n\n\n```sh\npip install heare-histograms\n```\n\n# Usage\n## Histogram\nThe Histogram class can be imported and used as follows:\n\n```python\nfrom heare.histograms import Histogram, Shift, Scale, Max\n\n# Create a new histogram\nhist = Histogram[int](max_size=1000)\n\n# Observe data points\nhist.observe([1, 2, 3, 4, 5])\n\n# Sample a data point\nsample = hist.sample()\n\n# Get the value at a given percentile\npercentile_val = hist.percentile(0.9)\n\n# Combine two histograms\nhist2 = Histogram[int](data=[10, 20, 30])\ncombined = hist + hist2\n\n# Apply transformations to the histogram\nshifted_hist = Shift(hist, 10)\nscaled_hist = Scale(hist, 2.0)\ncapped_hist = Max(hist, 100)\n```\nThe Histogram class supports various operations, such as observing new data points, sampling, computing percentiles, combining histograms, and applying transformations like shifting, scaling, and capping values.\n\n# Group\nThe Group class can be imported and used as follows:\n\n```python\nfrom heare.histograms import Histogram, Group\n\n# Create a new group with two histograms\nhist1 = Histogram[int](data=[1, 2, 3])\nhist2 = Histogram[int](data=[10, 20, 30])\ngroup = Group[int]([(\"hist1\", hist1), (\"hist2\", hist2)])\n\n# Sample a value from the group\nsample = group.sample()\n\n# Explain the sampled value\nexplanation = group.explain_sample()\n```\nThe Group class allows you to combine multiple Histogram instances or other Group instances into a single entity. You can sample values from the group and obtain an explanation of the sampled value, breaking it down into contributions from each element.\n\n\n# Contributing\nContributions to the library are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/heare-io/heare-histograms).\n\n# License\nThis library is released under the [MIT License](https://opensource.org/license/mit).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Pure python histogram implementation for analysis and prediction.",
"version": "0.1.3",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "69852b9c524cfea1e0f45a835c11d62042c89a133bbb8363f4ea6b23d8eb783c",
"md5": "d04efa389395279f11eda7fb5baef829",
"sha256": "bc5d1f888401d0387728975c6755664cc4e4924e30a57278b6fcd7b8f59a087e"
},
"downloads": -1,
"filename": "heare_histograms-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d04efa389395279f11eda7fb5baef829",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 6184,
"upload_time": "2024-05-30T00:34:10",
"upload_time_iso_8601": "2024-05-30T00:34:10.263029Z",
"url": "https://files.pythonhosted.org/packages/69/85/2b9c524cfea1e0f45a835c11d62042c89a133bbb8363f4ea6b23d8eb783c/heare_histograms-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5efdb4c48a70dcb6ece91e6e32aaa4649fb6385134a2c35624ab82636b3a6f2e",
"md5": "2270ed88520c68beafd95fefae397c70",
"sha256": "012af29c90004dbb9f16d82aa489d841ad1f775ebda7bdd610cd8f33fc4ca5ff"
},
"downloads": -1,
"filename": "heare_histograms-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "2270ed88520c68beafd95fefae397c70",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 5255,
"upload_time": "2024-05-30T00:34:11",
"upload_time_iso_8601": "2024-05-30T00:34:11.792302Z",
"url": "https://files.pythonhosted.org/packages/5e/fd/b4c48a70dcb6ece91e6e32aaa4649fb6385134a2c35624ab82636b3a6f2e/heare_histograms-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-30 00:34:11",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "heare-histograms"
}