heare-histograms


Nameheare-histograms JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryPure python histogram implementation for analysis and prediction.
upload_time2024-04-15 03:26:19
maintainerNone
docs_urlNone
authorSean Fitzgerald
requires_python<4.0,>=3.11
licenseMIT
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/3f/60/1ec64e9b80ef5ae3a56a9d5d42b7be64124e5f7a12b0222082978a340eac/heare_histograms-0.1.2.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.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "925bdeee3f16d0f65daa53fca48d7f36f40f04f20d803b0b74cd2d9e5476cc12",
                "md5": "62dbe8722310d2e90496fbf3519cc0a7",
                "sha256": "0f55ad2bfbf7b55c9249bc818523109396586f179206b3522d2578ae4fc99d09"
            },
            "downloads": -1,
            "filename": "heare_histograms-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "62dbe8722310d2e90496fbf3519cc0a7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 6149,
            "upload_time": "2024-04-15T03:26:17",
            "upload_time_iso_8601": "2024-04-15T03:26:17.980742Z",
            "url": "https://files.pythonhosted.org/packages/92/5b/deee3f16d0f65daa53fca48d7f36f40f04f20d803b0b74cd2d9e5476cc12/heare_histograms-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f601ec64e9b80ef5ae3a56a9d5d42b7be64124e5f7a12b0222082978a340eac",
                "md5": "e8714f5c8ea46ee7d9e02d6ec37578e1",
                "sha256": "7b4d868728cbbe8331dc880e610418b8321050149f9b66e9b0aff5bf8cc540bd"
            },
            "downloads": -1,
            "filename": "heare_histograms-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e8714f5c8ea46ee7d9e02d6ec37578e1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 5226,
            "upload_time": "2024-04-15T03:26:19",
            "upload_time_iso_8601": "2024-04-15T03:26:19.452731Z",
            "url": "https://files.pythonhosted.org/packages/3f/60/1ec64e9b80ef5ae3a56a9d5d42b7be64124e5f7a12b0222082978a340eac/heare_histograms-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 03:26:19",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "heare-histograms"
}
        
Elapsed time: 0.29563s