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.3-cp38-cp38-win_amd64.whl (111.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

KDEpy-1.0.3-cp38-cp38-win32.whl (98.6 kB view details)

Uploaded CPython 3.8 Windows x86

KDEpy-1.0.3-cp38-cp38-manylinux2010_x86_64.whl (420.0 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

KDEpy-1.0.3-cp38-cp38-manylinux1_x86_64.whl (420.0 kB view details)

Uploaded CPython 3.8

KDEpy-1.0.3-cp38-cp38-macosx_10_9_x86_64.whl (116.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

KDEpy-1.0.3-cp37-cp37m-win_amd64.whl (110.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

KDEpy-1.0.3-cp37-cp37m-win32.whl (97.2 kB view details)

Uploaded CPython 3.7m Windows x86

KDEpy-1.0.3-cp37-cp37m-manylinux2010_x86_64.whl (383.7 kB view details)

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

KDEpy-1.0.3-cp37-cp37m-manylinux1_x86_64.whl (383.7 kB view details)

Uploaded CPython 3.7m

KDEpy-1.0.3-cp37-cp37m-macosx_10_9_x86_64.whl (115.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

KDEpy-1.0.3-cp36-cp36m-win_amd64.whl (110.2 kB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m Windows x86

KDEpy-1.0.3-cp36-cp36m-manylinux2010_x86_64.whl (384.2 kB view details)

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

KDEpy-1.0.3-cp36-cp36m-manylinux1_x86_64.whl (384.2 kB view details)

Uploaded CPython 3.6m

KDEpy-1.0.3-cp36-cp36m-macosx_10_9_x86_64.whl (115.3 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file KDEpy-1.0.3-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: KDEpy-1.0.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 111.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for KDEpy-1.0.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b429026456d6488e5a10a543855944f20d73ad59056e65735879178e90d42966
MD5 a0d88d609aca274eaf980c66f3194daf
BLAKE2b-256 caf72e128c8190d9ea33d95fe761400cbf6026ae4df8dd6de9711e49dc715a66

See more details on using hashes here.

File details

Details for the file KDEpy-1.0.3-cp38-cp38-win32.whl.

File metadata

  • Download URL: KDEpy-1.0.3-cp38-cp38-win32.whl
  • Upload date:
  • Size: 98.6 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for KDEpy-1.0.3-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 00015e38929d92d79dc4a1f12ada26a579c0682b306bf1115db13b978b2919d1
MD5 bad6b0c354321341bd2674d96e11bfb6
BLAKE2b-256 264febfdf9e7747f712ccf7a4755896eccdb51eceef6e315facf856d149d0704

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 420.0 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.6.7

File hashes

Hashes for KDEpy-1.0.3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 c6b6183093c6041cc32de8458c96158cd1b4fd75e38542f3cc3a17399ba2b140
MD5 daea3dcfb9afb8d7faf8a1f61029de20
BLAKE2b-256 107197ebfebaf858c41312091152bee82e80f1b491e650274f6e526e15d13acc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 420.0 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.6.7

File hashes

Hashes for KDEpy-1.0.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2477efb76f18877a47a14bd24574e95d3535711e07197e1e7ec537b44865e1e7
MD5 34eab54ddd3a085df27c698a23798038
BLAKE2b-256 f6a10a13f7e17c86d6082bafcf83320dad092e3d59429671dbaf8c7ad9654070

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 116.6 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for KDEpy-1.0.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 44bc8d9d7c2696951db323e0a099e45a0898d582f9282f8f6300d93ee499c910
MD5 b339abe2f27f60ea65dc659a3ce8add5
BLAKE2b-256 90901dd3bf414ada12fe2ce430f120c3600c93c006901137e25bfd0aee1f8345

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 110.2 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for KDEpy-1.0.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 e63befd8a5b8f0ffcd84a4d3fb7a9feae23a19f3407818d3a41e4eba45b5c11a
MD5 f039b669cf6b6a9be1b77890c10db610
BLAKE2b-256 82f99dc0939d07a23ce59c7dd6ccbf4f61a683c65972484f77205c5e64eddd02

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 97.2 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for KDEpy-1.0.3-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 bbfeb4dd267081bde4eb0eb21f7376f85689eef9f582b2bd43092c1a293da909
MD5 c00ced1fd96e24b96eec688d1213e119
BLAKE2b-256 bd15c1eb329723af8b3ce31fe0658f469a9b9799bc9a7ea655d2ea7c60b22fe9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 383.7 kB
  • Tags: CPython 3.7m, 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.6.7

File hashes

Hashes for KDEpy-1.0.3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4f95f7984fa451f8a4c01ed763060d060c62b57f611ea79814de010fe82bba8c
MD5 c5b2b697af513db7b7048d9dd95e1d2c
BLAKE2b-256 6e7aae429abb1834321827fb0d7dfeaa1eda5be3d78479854abb65d5728ca692

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 383.7 kB
  • Tags: CPython 3.7m
  • 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.6.7

File hashes

Hashes for KDEpy-1.0.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d0a29ffee5386ab7c68c34e1864d5284f1d889aff13d39f8cee4524413edad0e
MD5 1a55b50c59e435fb54ed3566c61234dd
BLAKE2b-256 db67f93f4328145515becbb255323f74c5aea8b0afde26b873380fef91b40c97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 115.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for KDEpy-1.0.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ed05b3b99492e4aa82827520ab0d9e3fc8f077f6a02446ec16e4f3618b430866
MD5 1bd7ebf9369ffc6ae177f005c012f91f
BLAKE2b-256 a0924f5821f049d535958a67281e0cf61822ca7184a2ab76d8a3d2f62759a193

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 110.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for KDEpy-1.0.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 672c907ff2c9c95913a0b3a4fba90e5d1e0ab324894e5bf28abe67ea6a9c4b6e
MD5 7ea0f958cd5851e694c9cfb899d1069e
BLAKE2b-256 fa5e8039a48956f9bf892018cec9424dbcb0e65c8e30d12c12baef4329abb5d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 97.2 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for KDEpy-1.0.3-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 764b050e3d0cd0eb9537f046ed44706d75cea1df3e1375e5b2d19e6cf071aeaf
MD5 9b43c31e2af2290cfac15149b0cf3b4c
BLAKE2b-256 c34ae63373038ec004b54e7952b079fcb314a6804b1370f40a444b7e497a52ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 384.2 kB
  • Tags: CPython 3.6m, 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.6.7

File hashes

Hashes for KDEpy-1.0.3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 169e3dc4e269d6e5a6ae13d1034da32f76c074da1720257f5f434a17c354cc74
MD5 f7f70ee515c9793f6a0cb0fbb42b49bf
BLAKE2b-256 e54f8b7ba4961a8ba5c128df7021fd44a9e889df760c9282e520207f8ba6aa93

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 384.2 kB
  • Tags: CPython 3.6m
  • 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.6.7

File hashes

Hashes for KDEpy-1.0.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5014eaa3419ad347e5cd28ff267460c814cdd7acc77f33dd43d52e72efd196a5
MD5 ce8dbbbb19b0649389209ff59cfb1acc
BLAKE2b-256 7b1faedee316dc79fd2b75e3ffa626c1df0ec0652641d19c748cb461cc43f067

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.3-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 115.3 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for KDEpy-1.0.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 741188ad5b16c4bba28bd5f6cf155050cfea49f51ec9b715e2fe3fc57550c18c
MD5 bd416f7a4a5eff5379f874c2a748844c
BLAKE2b-256 83c2dfd9a6cacf376f2bb61001fdb85dcef4311ece6a4d962b6be7f45df6894f

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