Skip to main content

Pure python histogram implementation for analysis and prediction.

Project description

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:

pip install heare-histograms

Usage

Histogram

The Histogram class can be imported and used as follows:

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:

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.

License

This library is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

heare_histograms-0.1.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

heare_histograms-0.1.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file heare_histograms-0.1.3.tar.gz.

File metadata

  • Download URL: heare_histograms-0.1.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for heare_histograms-0.1.3.tar.gz
Algorithm Hash digest
SHA256 012af29c90004dbb9f16d82aa489d841ad1f775ebda7bdd610cd8f33fc4ca5ff
MD5 2270ed88520c68beafd95fefae397c70
BLAKE2b-256 5efdb4c48a70dcb6ece91e6e32aaa4649fb6385134a2c35624ab82636b3a6f2e

See more details on using hashes here.

File details

Details for the file heare_histograms-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for heare_histograms-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bc5d1f888401d0387728975c6755664cc4e4924e30a57278b6fcd7b8f59a087e
MD5 d04efa389395279f11eda7fb5baef829
BLAKE2b-256 69852b9c524cfea1e0f45a835c11d62042c89a133bbb8363f4ea6b23d8eb783c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page