You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-98Lines changed: 1 addition & 98 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,28 +10,7 @@
10
10
11
11
Khisto is a Python library for creating histograms using the **Khiops optimal binning algorithm**. Unlike standard histograms that use fixed-width bins or simple heuristics, Khisto automatically determines the optimal number of bins and their variable widths to best represent the underlying data distribution.
12
12
13
-
## Features
14
-
15
-
-**Optimal Binning**: Uses the MODL (Minimum Description Length) principle to find the best discretization.
16
-
-**Variable-Width Bins**: Captures dense regions with fine bins and sparse regions with wider bins.
17
-
-**NumPy Compatible**: Drop-in replacement for `numpy.histogram`.
18
-
-**Matplotlib Integration**: `khisto.matplotlib.hist` works like `plt.hist`.
19
-
-**Core Histogram API**: Inspect every available granularity with `khisto.core.compute_histograms` and `HistogramResult`.
20
-
-**Minimal Dependencies**: Only requires NumPy (matplotlib optional for plotting).
n, bins, patches = hist(long_tail_data, density=True)
87
-
plt.xscale("log")
88
-
plt.yscale("log")
89
-
plt.show()
90
-
```
91
-
92
-
### Matplotlib Integration
93
-
94
-
```python
95
-
import numpy as np
96
-
import matplotlib.pyplot as plt
97
-
from khisto.matplotlib import hist
98
-
99
-
# Generate 10,000 samples from a standard Gaussian distribution.
100
-
data = np.random.normal(0, 1, 10000)
101
-
102
-
# Density is usually the most interpretable view with variable-width bins.
103
-
n, bins, patches = hist(data, density=True)
104
-
plt.xlabel('Value')
105
-
plt.ylabel('Density')
106
-
plt.show()
107
-
108
-
# Cumulative density follows matplotlib semantics.
109
-
n, bins, patches = hist(data, density=True, cumulative=True)
110
-
plt.ylabel('Cumulative probability')
111
-
plt.show()
112
40
```
113
41
114
-
## How It Works
115
-
116
-
Khisto uses the Khiops optimal binning algorithm based on the MODL (Minimum Optimal Description Length) principle. Instead of using fixed-width bins like traditional histograms, it:
117
-
118
-
1. Analyzes the data distribution
119
-
2. Finds bin boundaries that minimize information loss
120
-
3. Creates variable-width bins that adapt to data density
121
-
122
-
This results in histograms that better represent the underlying distribution, with finer bins in dense regions and wider bins in sparse regions.
123
-
124
-
The method implemented in Khiops is comprehensively detailed in [2] and further extended in [1].
125
-
126
-
-[1] M. Boullé. Floating-point histograms for exploratory analysis of large scale real-world data sets. Intelligent Data Analysis, 28(5):1347-1394, 2024
127
-
-[2] V. Zelaya Mendizábal, M. Boullé, F. Rossi. Fast and fully-automated histograms for large-scale data sets. Computational Statistics & Data Analysis, 180:0-0, 2023
128
-
129
42
## Development
130
43
131
44
```bash
@@ -140,16 +53,6 @@ uv sync --group dev --extra all
140
53
uv run pytest
141
54
```
142
55
143
-
## Documentation
144
-
145
-
Full documentation is hosted at **[khiops.github.io/khisto-python](https://khiops.github.io/khisto-python/)**.
146
-
147
-
-[API Reference](https://khiops.github.io/khisto-python/array/histogram/index.html) — NumPy-like histogram API
148
-
-[Matplotlib Integration](https://khiops.github.io/khisto-python/matplotlib/index.html) — `hist` plotting function
149
-
-[Core API](https://khiops.github.io/khisto-python/core/index.html) — full access to histogram granularity levels
150
-
-[API Comparison](https://khiops.github.io/khisto-python/api_comparison.html) — side-by-side with NumPy and Matplotlib
0 commit comments