Jensen-Shannon Centroid
A lightweight python package to calculate the Jensen-Shannon Centroid of a set of categorical distributions. The Jensen-Shannon Centroid is the minimizer Q of the equation:
$$\mathcal{L}(Q) = \sum_{m} \text{JS}(Q\|p_{m})$$
where JS is the Jensen-Shannon divergence. We follow the ConCave–Convex procedure (CCCP) from Nielsen, 2020 to find Q.
Nielsen, Frank. 2020. "On a Generalization of the Jensen–Shannon Divergence and the Jensen–Shannon Centroid" Entropy 22, no. 2: 221. https://doi.org/10.3390/e22020221
Installation
Install directly using pip:
$ pip install jensen-shannon-centroid
Dependencies
numpy
Usage
There is one main method, jensen_shannon_centroid.calculate_jsc. This method takes in a list of size $M\times N\times K$ where:
- $K$ is the number of classes in each distribution
- $N$ is a set of different distributions each having $K$ classes
- $M$ are the different views of each distribution for which the Jensen-Shannon centroid will be calculated
The method will return an array of size $N\times K$, which are the Jensen-Shannon centroids of the set of $M$ different views of each of the $N$ distributions.
Here is an example usage:
from jensen_shannon_centroid import calculate_jsc
distributions = [
[[0.1, 0.9],
[0.2, 0.8]],
[[0.15, 0.85],
[0.5, 0.5 ]]
]
calculate_jsc(distributions)
>>>returns: array([[0.12391947, 0.87608053],
[0.34213098, 0.65786902]])
Metadata
Release files for jensen-shannon-centroid 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jensen-shannon-centroid-1.0.tar.gz | 3.6 kB | Without provenance | Details for jensen-shannon-centroid-1.0.tar.gz |
Release files / jensen-shannon-centroid-1.0.tar.gz
| Download URL | jensen-shannon-centroid-1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
243dfdfc3079c87e6f2d789ab4b2430d85532089c39dc1caffece143b97d06bb
|
|
BLAKE2b-256 checksum How to use checksums |
245e1bdcbf8a9c0d47769052db7ad0ee45c3b9585c53bf192150843c18867aae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.15
|
Security for jensen-shannon-centroid 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.