SpatialEntropy
This is a python implementation of spatial entropy, inspired by the R package spatentropy. For now, two spatial entropy methods have been implemented:
- Leibovici’s entropy
- Altieri's entropy
Compare with shannon entropy
Installation
It's available on PyPI
pip install spatialentropy
Usage
Let's generate some fake data first:
import numpy as np
points = 100 * np.random.randn(10000, 2) + 1000
types = np.random.choice(range(30), 10000)
Here we have 10,000 points and then we assigned each point with a category from 30 categories.
Quick start
from spatialentropy import leibovici_entropy
e = leibovici_entropy(points, types)
e.entropy
Leibovici entropy
To calculate the leibovici entropy, we need to set up a distance or an interval to define the co-occurrences.
from spatialentropy import leibovici_entropy
# set the distance cut-off to 5
e = leibovici_entropy(points, types, d=5)
# if you want to change the base of log
e = leibovici_entropy(points, types, base=2)
e.entropy # to get the entropy value
e.adj_matrix # to get the adjacency matrix
e.pairs_counts # to get the counts for each pair of co-occurrences
Altieri entropy
To calculate the altieri entropy, we need to set up intervals to define the co-occurrences.
from spatialentropy import altieri_entropy
# set cut=2, it means we will create 3 intervals evenly from [0,max]
e = altieri_entropy(points, types, cut=2)
# or you want to define your own intervals
e = altieri_entropy(points, types, cut=[0,4,10])
e.entropy # to get the entropy value, e.entropy = e.mutual_info + e.residue
e.mutual_info # the spatial mutual information
e.residue # the spatial residue entropy
e.adj_matrix # to get the adjacency matrix
Metadata
Release files for spatialentropy 0.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 |
|---|---|---|---|---|
| spatialentropy-0.1.0.tar.gz | 5.3 kB | Without provenance | Details for spatialentropy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spatialentropy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for spatialentropy-0.1.0-py3-none-any.whl |
Total release size: 12.1 kB
Release files / spatialentropy-0.1.0.tar.gz
| Download URL | spatialentropy-0.1.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4019c3487e66f94a6095441adb50781ddb977614db6dffd6113dd57faffab24
|
|
BLAKE2b-256 checksum How to use checksums |
2a889201d1a0050b8d650f1562944d5c88bfafb49c42728c3620ce105d785128
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.0
|
Release files / spatialentropy-0.1.0-py3-none-any.whl
| Download URL | spatialentropy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50cd0a1256d9c3f9730e891e42384e5f3ca05e52f21f746f6823feb3d4a88760
|
|
BLAKE2b-256 checksum How to use checksums |
f8270dc174e638873627a106f8de1a37fe803231fb9365205d09d0837eb08502
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.0
|
Security for spatialentropy 0.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.