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.6+ 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. The code is stable and in widespread by practitioners and in other packages.

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 showing an unweighted and weighted kernel density. 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
import matplotlib.pyplot as plt

customer_ages = [40, 56, 20, 35, 27, 24, 29, 37, 39, 46]

# Distribution of customers
x, y = FFTKDE(kernel="gaussian", bw="silverman").fit(customer_ages).evaluate()
plt.plot(x, y)

# Distribution of customer income (weight each customer by their income)
customer_income = [152, 64, 24, 140, 88, 64, 103, 148, 150, 132]

# The `bw` parameter can be manually set, e.g. `bw=5`
x, y = FFTKDE(bw="silverman").fit(customer_ages, weights=customer_income).evaluate()
plt.plot(x, y)

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

KDEpy-1.0.7-cp38-cp38-manylinux2010_x86_64.whl (432.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

KDEpy-1.0.7-cp38-cp38-manylinux2010_i686.whl (406.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

KDEpy-1.0.7-cp38-cp38-manylinux1_x86_64.whl (432.4 kB view details)

Uploaded CPython 3.8

KDEpy-1.0.7-cp38-cp38-manylinux1_i686.whl (406.5 kB view details)

Uploaded CPython 3.8

KDEpy-1.0.7-cp38-cp38-macosx_10_9_x86_64.whl (116.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

KDEpy-1.0.7-cp37-cp37m-manylinux2010_x86_64.whl (396.1 kB view details)

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

KDEpy-1.0.7-cp37-cp37m-manylinux2010_i686.whl (371.5 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

KDEpy-1.0.7-cp37-cp37m-manylinux1_x86_64.whl (396.1 kB view details)

Uploaded CPython 3.7m

KDEpy-1.0.7-cp37-cp37m-manylinux1_i686.whl (371.5 kB view details)

Uploaded CPython 3.7m

KDEpy-1.0.7-cp37-cp37m-macosx_10_9_x86_64.whl (115.8 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

KDEpy-1.0.7-cp36-cp36m-manylinux2010_x86_64.whl (396.6 kB view details)

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

KDEpy-1.0.7-cp36-cp36m-manylinux2010_i686.whl (370.4 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

KDEpy-1.0.7-cp36-cp36m-manylinux1_x86_64.whl (396.6 kB view details)

Uploaded CPython 3.6m

KDEpy-1.0.7-cp36-cp36m-manylinux1_i686.whl (370.4 kB view details)

Uploaded CPython 3.6m

KDEpy-1.0.7-cp36-cp36m-macosx_10_9_x86_64.whl (115.4 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: KDEpy-1.0.7-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 432.4 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7c817f10a798d1490193652662b9fcfb285d40680f48671f7fde29ecd40977a4
MD5 ca08f80038ac4aff2311d90cccd244f4
BLAKE2b-256 2beced01cd3411469edfe3a04846c5f7580a017b0d1d7ee626d67de755f2fe5a

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp38-cp38-manylinux2010_i686.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp38-cp38-manylinux2010_i686.whl
  • Upload date:
  • Size: 406.5 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp38-cp38-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 a17606b8f22d7386974c03030af7c0bbab34a88d025e9ada076a9d1a40ebdbe9
MD5 826fef840681a9fb420e59e31fc007a1
BLAKE2b-256 a8086b9aac54480c8a7b6fb990595045f9e20bc445a7c2e37389d0a3090d11e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.7-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 432.4 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 153c4ab57b3617c58fa21b7e3fd72e82a4c7a81867d2ac3525bf205ffb6ac87b
MD5 230a8479b432d223bb62071000298504
BLAKE2b-256 c159612e10bc4bc14b30013853f3ddfb5f583f37e229324a010565797d6d7546

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp38-cp38-manylinux1_i686.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 406.5 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 7ddc49cc0fa86238cb0ef368a662995d1d279b6d6291cfaa911d1c942f92528a
MD5 fd12caced65b6542603228414c74e848
BLAKE2b-256 c09c27c3aea067922ca53152b25fbe0a8f89f07fafee08eb522fb6efe20eeac6

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 116.7 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.4

File hashes

Hashes for KDEpy-1.0.7-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 508b37b5508ae82f09fd245793429d1a118d948e91c243c1e89a6bec75f643cd
MD5 d2e0d9d8039ec03ab32280132a312fea
BLAKE2b-256 48070474e8d10b40c10641e9ebaf4cb094c1c2250fe01a09cf7daadfc3ac9691

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.7-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 396.1 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ee0520869878259a8f67865a25ccf0e3b7709d151a12fa6b5f7f7cb83c4802c3
MD5 e8e5e3159cece4ca85a8974db6333d47
BLAKE2b-256 7254fb0d1b22d05b3c83ce7bbb69982f2fed90eb5a7c4ff56117518e137603fe

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp37-cp37m-manylinux2010_i686.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp37-cp37m-manylinux2010_i686.whl
  • Upload date:
  • Size: 371.5 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp37-cp37m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 7e148ce332331cb9ce20add539876a270763af4fd03ef2686f2f0bfbccc3c499
MD5 e2363aed42ef0a406086a1f6eae764ec
BLAKE2b-256 005c74621aae30e466ce1d8774e1c21cd77235b4ce38ab9c25d34651ed36347c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.7-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 396.1 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9e2a2b4ce7f1d2b61c91cbfb5504299831a54dbaed4184e8006b62f171861afd
MD5 1416e6cf33460f0229ad204e5fa4f527
BLAKE2b-256 51ca39f0f2712731838b8c6ab232e806a96106886ff4aaa1ca9ad28b4bfc79eb

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 371.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 45783f7b7ac64f898bbc54c95bbb22983f0f30d5725722fd59362bde41cfae87
MD5 bb9d295674f931d84952f6d5be3d615b
BLAKE2b-256 c855bca3d42f831e9dc5353309910af485e190cee241f09a7e1062d569d80d4e

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 115.8 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.4

File hashes

Hashes for KDEpy-1.0.7-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dc067a922e87b161a583efa7ec575b70707d4771e28481b0a26a66eaea135572
MD5 f497cca770b36186293c7743c7074d4a
BLAKE2b-256 8225fc4e6c06b476b91f5b7949da3a5c2d10b4bc85e8eece203c4d62e746bc7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.7-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 396.6 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1c05c63b32099030701d9a56cf8b3e63b02469e457f9ba8c7593ab02b7924264
MD5 b8720b2a5ddf9bd5bf9418990a42b024
BLAKE2b-256 3eb3966edc6096cf53deadff7b898b6f2c599cf3bc6cfe70dc50ee87670990eb

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp36-cp36m-manylinux2010_i686.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp36-cp36m-manylinux2010_i686.whl
  • Upload date:
  • Size: 370.4 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp36-cp36m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 7a22a8d2c95ed51843eff3c0dc079451d97f52349e7bf1746623ef9ef379faf5
MD5 db099443b095020d7f3167b6b697ae05
BLAKE2b-256 d2999acd6357a2ed0499732a4cdff2c998b02990f0638229b541a12db7b12f77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.7-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 396.6 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 496c990d1033cc9c3927f0ba4081fdfd680017c97e04bfbe25729298dd3f491d
MD5 9c174eadf117413dc2bec0ad332dd6b8
BLAKE2b-256 81bbc02a59449d114da5ea75d93c35d9cef698ae1461153e35385a4bfcffae97

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 370.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.1

File hashes

Hashes for KDEpy-1.0.7-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 38e0cfb36ed8d3eda091d9645e6c744e4b0018205cf252ad22abca8ac829ffb0
MD5 573f0897ce5683fa0ad33d8fc8dd5104
BLAKE2b-256 85ca2fc805d3dade86d05afb5ae14158a60ac3820b83e4703ab6e58931b266a1

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.7-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.7-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 115.4 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.4

File hashes

Hashes for KDEpy-1.0.7-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 938c57ea275824fdab94ad13d94c9f7bd07b00242cc6d0d40002efd5cc5a6463
MD5 d6e25217ae56a0e10b5c3055d2b9829c
BLAKE2b-256 9bc5b0aae83854135dd4512f9b754322540b5b9049136dc72864136406a3f5d0

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