Skip to main content

Empirical density estimation in python

empdens provides a unified interface to several density estimation packages, including an implementation of classifier-adjusted density estimation. Examples include

Applications of density estimation include

  • Detecting data drift: The reliability of a trained model's prediction at a new data point depends on the similarity between the new point and the training data. A density function trained on the training data can serve as a warning of data drift if the evaluated density at the new point is exceptionally low. One way to focus such an analysis is to train and evaluate the density using only several of the most-important features in the model.
  • Mode detection: Locating regions of high density is a first step to efficiently allocate resources to address an epidemic, market a product, etc.
  • Feature engineering: The density at a point with respect to any subset of the dimensions of a feature space can encode useful information.
  • Anomaly/novelty/outlier detection: A "point of low density" is a common working definition of "anomaly", although it's not the only one. (In astrostatistics, for example, a density spike may draw attention as a possible galaxy.)

Evaluating the performance of a density estimator is not straightforward. We rely on a mix of simulation, real-data sanity checks, and cross-validation in special cases, as detailed in our evaluation guide.

Installation

We're on pypi, so pip install empdens.

To keep the package lean, several packages that it's capable of using are not included as required dependencies. So, depending on your usage, you may get an error message reminding you to install any of the packages listed under the extras group in the pyproject.toml file.

Consider using the simplest-possible virtual environment if working directly on this repo.

Related work

Wishlist

Infrastructure:

  • expand code testing coverage
  • define new simulations

Tutorials, starting with

  • how CADE works
  • density estimation trees

Density estimation:

  • Implement a dimensionality-reduction pre-processing method. Extreme multicolinearly is a potential failure mode in CADE because the classifier can trivially distinguish fake data from real since the fake data model assumes feature independence.
  • Merge the best of the tree-based methods of LightGBM, detpack, Schmidberger and Frank, and astropy.stats.bayesian_blocks.

Metadata

Release files for empdens 1.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for empdens 1.4.4
File Size Uploaded
empdens-1.4.4.tar.gz 179.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for empdens 1.4.4
File Interpreter ABI Platform
empdens-1.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 366.0 kB

Release files / empdens-1.4.4.tar.gz

Download URL empdens-1.4.4.tar.gz
Size 179.8 kB
Tags Source
SHA-256 checksum
How to use checksums
006a409a507e3016325cccdad0ba1282ca4e2046485673509ffdb3718bce6837
BLAKE2b-256 checksum
How to use checksums
8022c887c3907167aef401bcdced36255f02c8ff5a0136ca0a3c5759f258df8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.11

Release files / empdens-1.4.4-py3-none-any.whl

Download URL empdens-1.4.4-py3-none-any.whl
Size 186.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1c090f54c19b009db531b027395701164e9ef5df531e3b897e0727a915dcc63
BLAKE2b-256 checksum
How to use checksums
85fbd0dc952fb590eeff6a554afd6255bab4deaba5d387d237273cb85d516e36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.11

Release history Release notifications | RSS feed

This release

1.4.4 This release

2 release files

1.4.2

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page