Skip to main content

Kernel Density Estimation in Python.

Project description

DOI Build Status Build status Documentation Status PyPI version Downloads

KDEpy

About

This Python 3.5+ package implements various kernel density estimators (KDE). Three algorithms are implemented through the same API: NaiveKDE, TreeKDE and FFTKDE. The class FFTKDE outperforms other popular implementations, see the comparison page.

Plot

The code generating the above graph is found in examples.py.

Installation

KDEpy is available through PyPI, and may be installed using pip:

pip install KDEpy

If you have trouble on Ubuntu, try running sudo apt install libpython3.X-dev, where 3.X is your Python version.

Example code and documentation

Below is an example using NumPy as np and scipy.stats.norm to plot a density estimate. From the code below, it should be clear how to set the kernel, bandwidth (variance of the kernel) and weights. See the documentation for more examples.

from KDEpy import FFTKDE
data = norm(loc=0, scale=1).rvs(2**3)
estimator = FFTKDE(kernel='gaussian', bw='silverman')
x, y = estimator.fit(data, weights=None).evaluate()
plt.plot(x, y, label='KDE estimate')

Plot

The package consists of three algorithms. Here's a brief explanation:

  • NaiveKDE - A naive computation. Supports d-dimensional data, variable bandwidth, weighted data and many kernel functions. Very slow on large data sets.
  • TreeKDE - A tree-based computation. Supports the same features as the naive algorithm, but is faster at the expense of small inaccuracy when using a kernel without finite support. Good for evaluation on non-uniform, arbitrary grids.
  • FFTKDE - A very fast convolution-based computation. Supports weighted d-dimensional data and many kernels, but not variable bandwidth. Must be evaluated on an equidistant grid, the finer the grid the higher the accuracy. Data points may not be outside of the grid.

Issues and contributing

Issues

If you are having trouble using the package, please let me know by creating an Issue on GitHub and I'll get back to you.

Contributing

Whatever your mathematical and Python background is, you are very welcome to contribute to KDEpy. To contribute, fork the project, create a branch and submit and Pull Request. Please follow these guidelines:

  • Import as few external dependencies as possible.
  • Use test driven development, have tests and docs for every method.
  • Cite literature and implement recent methods.
  • Unless it's a bottleneck computation, readability trumps speed.
  • Employ object orientation, but resist the temptation to implement many methods -- stick to the basics.
  • Follow PEP8.

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

KDEpy-1.0.2.tar.gz (136.7 kB view details)

Uploaded Source

Built Distributions

KDEpy-1.0.2-cp38-cp38-manylinux2010_x86_64.whl (419.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

KDEpy-1.0.2-cp38-cp38-manylinux1_x86_64.whl (419.9 kB view details)

Uploaded CPython 3.8

KDEpy-1.0.2-cp37-cp37m-win_amd64.whl (110.1 kB view details)

Uploaded CPython 3.7m Windows x86-64

KDEpy-1.0.2-cp37-cp37m-win32.whl (97.1 kB view details)

Uploaded CPython 3.7m Windows x86

KDEpy-1.0.2-cp37-cp37m-manylinux2010_x86_64.whl (383.6 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

KDEpy-1.0.2-cp37-cp37m-manylinux1_x86_64.whl (383.6 kB view details)

Uploaded CPython 3.7m

KDEpy-1.0.2-cp37-cp37m-macosx_10_6_intel.whl (193.3 kB view details)

Uploaded CPython 3.7m macOS 10.6+ intel

KDEpy-1.0.2-cp36-cp36m-win_amd64.whl (110.1 kB view details)

Uploaded CPython 3.6m Windows x86-64

KDEpy-1.0.2-cp36-cp36m-win32.whl (97.2 kB view details)

Uploaded CPython 3.6m Windows x86

KDEpy-1.0.2-cp36-cp36m-manylinux2010_x86_64.whl (384.0 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

KDEpy-1.0.2-cp36-cp36m-manylinux1_x86_64.whl (384.0 kB view details)

Uploaded CPython 3.6m

KDEpy-1.0.2-cp36-cp36m-macosx_10_6_intel.whl (192.9 kB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

KDEpy-1.0.2-cp35-cp35m-win_amd64.whl (109.8 kB view details)

Uploaded CPython 3.5m Windows x86-64

KDEpy-1.0.2-cp35-cp35m-win32.whl (96.6 kB view details)

Uploaded CPython 3.5m Windows x86

KDEpy-1.0.2-cp35-cp35m-manylinux2010_x86_64.whl (379.0 kB view details)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

KDEpy-1.0.2-cp35-cp35m-manylinux1_x86_64.whl (379.0 kB view details)

Uploaded CPython 3.5m

KDEpy-1.0.2-cp35-cp35m-macosx_10_6_intel.whl (190.7 kB view details)

Uploaded CPython 3.5m macOS 10.6+ intel

File details

Details for the file KDEpy-1.0.2.tar.gz.

File metadata

  • Download URL: KDEpy-1.0.2.tar.gz
  • Upload date:
  • Size: 136.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3

File hashes

Hashes for KDEpy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6ddeae3f5e20d195b4c60f3416dd8fec08838e16a6f3c8dc857a1fc28f0e58a9
MD5 5c6b4372ee63bce278021883f03e81ec
BLAKE2b-256 c9ff0229a6cb3df501d2c1908b6a1c036389e695d4f888c502191471e3f2003e

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 419.9 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 94daf5064678a923c9332d1bb92333ebbdf52b121a58540bcbff5aef8c0448d0
MD5 2cb32833c6d287756c8f35508a74b4c9
BLAKE2b-256 222048f2321586cb10b0ac498913544acf67f5a760e102870ba99bab6a548ff0

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 419.9 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 eb18675e6cd415cde398e50d08248274a8832c69323c8c0556fc6db7a618df7a
MD5 2d9c94710113a0cf77d43d0992c31633
BLAKE2b-256 64e0b28952bea6356da0e14fd69acb72b64a0b8f651997c5665eaecf5aab935a

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 110.1 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for KDEpy-1.0.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 dad68717136964ef5d07919be3e7a1bf4cd2a0d1c943811ddafa0815a4114403
MD5 85f5cf41ced39bfe7bf77edf5f16dc02
BLAKE2b-256 6c4c8d671ac59491c4330a465a7ceac0c19060526de996e4f70652637310d431

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp37-cp37m-win32.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 97.1 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for KDEpy-1.0.2-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 c69a33897fcb62655c5b8ca509857ff86fdbf5fcd92006691a31ea8b21d6b821
MD5 3d2e13699f51d284a3ca55a1ccc3cd11
BLAKE2b-256 3d891dcdb16b67a531f7ae35c61c342dccec93dfc6d4eb01290a5037f4bf326e

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 383.6 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

File hashes

Hashes for KDEpy-1.0.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 39ec7ee0b792e51e7a4bf203be744ccd0b0c665b838a2233e52034d7861a9905
MD5 c45b63e172a3dcc2ae005f157ac36dc6
BLAKE2b-256 65eee375b22921835a4d38c18a653e6da40b032dfd7e7a330bd657e77dd206a5

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 383.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

File hashes

Hashes for KDEpy-1.0.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 edaabd9854608e2f64e39606aa384bda2ceb49b7bc5fe5d44a8d4b61e19287ba
MD5 0eb7931a4cb7aaf844496cc4e9cd3ad9
BLAKE2b-256 5dd70370313a016f6f2e20a75e9456545a46a518336acbbe700935e48da82032

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 193.3 kB
  • Tags: CPython 3.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0

File hashes

Hashes for KDEpy-1.0.2-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 858e09a9ea1cdff42b944d07fbfdc3d58bea5b64f1fcfc79d32b742e7627094c
MD5 b976ae5e4d5dbbbb16b33f8895e7b43f
BLAKE2b-256 59e0e6d01f0a16fc1f7868a6f48a28683daa1d577cd4f3136d680e6de775182a

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 110.1 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for KDEpy-1.0.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 45586faab8173a9298a7c0a44c40e26ae64b20f4de589fdcf911a722e094ba80
MD5 6d439bcdd2a028d2ea37c0ba0d573dbf
BLAKE2b-256 9f5f99e33f3161841bb848ea061187875096e997a79d0d020f02077b29233565

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp36-cp36m-win32.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 97.2 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for KDEpy-1.0.2-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 5efc56342777a20dc20e6d48292f0cb6cbcf42c7cdfff59769098b0bb9f89746
MD5 83180fad53b3ffd1c15f9c84b97d04b9
BLAKE2b-256 737f03c7045cc7ef398b6c635aec22602a92d0042ca50d1c2ce8b2607b849465

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 384.0 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

File hashes

Hashes for KDEpy-1.0.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 21a0540f9b7a19491afaf8c4795068a358603c748e1fb584b0c8c60d1ca0abc5
MD5 d06826bb8c9c74aebcb7ffd5e31843a2
BLAKE2b-256 15935200d0dd5ef1bc4eb4b5699a67a73cfad4a0ee1fdc3ba2f0038a3ce9afe7

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 384.0 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

File hashes

Hashes for KDEpy-1.0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4204b6346a7e898b1b51a0f5c64fc34fb4ad795d68550f0d5e0590798276e09c
MD5 7e02711351ca4a111dedb58be0abb78e
BLAKE2b-256 6db58d5dd787c766532c99047a452fbe362d4917ea49d866615c15604d559c91

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 192.9 kB
  • Tags: CPython 3.6m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0

File hashes

Hashes for KDEpy-1.0.2-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 e52ba340882419e59339ffd236bc92ff8acb86bfc6cd244296ee52f6335cfb9a
MD5 a8b7108b7b9bb5d0d987f52bc378b6ab
BLAKE2b-256 40bc9c99d99fa8ca3014343b168727408dcc31c86491b170f6eb0658507ea100

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 109.8 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for KDEpy-1.0.2-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 b1d328ccc5ac2afe09fb96a280e0add86937e69caafc55931f3afb98243d681a
MD5 ec75802de782117a959cadc06452343e
BLAKE2b-256 222155760767b3a6c99c6fb410dec3de9b1c7c2dc8ad76c1c34a4480f3070918

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp35-cp35m-win32.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 96.6 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for KDEpy-1.0.2-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 430a91907849b1339c3e3771671531b13650f1d2a6280cc860a655e74d87da8f
MD5 5ca709ebe795cbad7d056585fbe38c22
BLAKE2b-256 1d4779a4f0fde3e798e5dd5dc4bd62930e6571b8c26c4ef6ae847569519fdf54

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp35-cp35m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp35-cp35m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 379.0 kB
  • Tags: CPython 3.5m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

File hashes

Hashes for KDEpy-1.0.2-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e3a8822a2b88b3e8e41a92ba1a03b1d3e7ead36fa1b46ef8362a1c514aa84028
MD5 ba78e9d4ba008da2c021b93c002dd38e
BLAKE2b-256 4513de2ea6eda930e2faf306d288e60eabc8e7babd94030ed72c12dc69f51896

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 379.0 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7

File hashes

Hashes for KDEpy-1.0.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0f06fb14d0b005b2d1e5fa9dc74394cc55ed09a506cfb31adb48011867fc8174
MD5 b6e70e404292b84eaf7986ae7af18446
BLAKE2b-256 5a3a2c782d79f94359d20d98afc1c28f251905727ccc15146ac7d07f23d4fce7

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.2-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

  • Download URL: KDEpy-1.0.2-cp35-cp35m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 190.7 kB
  • Tags: CPython 3.5m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0

File hashes

Hashes for KDEpy-1.0.2-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 708dc40b9334ff7a90e58db146fda4d5ef5d6f60b69d4c88fbfa246f540f250d
MD5 e8c71543b43489a1c9bac6b5e5de5a71
BLAKE2b-256 627bb9e1b6cfc9649550644da13f0a4bce1f6fd2e32817d6f7df6b0bd5b040c7

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