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.6-cp38-cp38-manylinux2010_x86_64.whl (432.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8

KDEpy-1.0.6-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.6-cp37-cp37m-manylinux2010_x86_64.whl (396.1 kB view details)

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

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

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7m

KDEpy-1.0.6-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.6-cp36-cp36m-manylinux2010_x86_64.whl (396.6 kB view details)

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

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

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

KDEpy-1.0.6-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.6-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a07ff8c3e75f45e20005af44dddac04f76a96b1ec987795d48d0a13e3db28e28
MD5 c3418647dd9504308a66e8d703a4e8c9
BLAKE2b-256 d51cdb12d3d6413d12a304d6f023be6c50af6f685580346cceba878b46cc688b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp38-cp38-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 b2201078b2653c2baa1711d3235e4e9f6a5c6d14d979a6fb491c4ccc977aa929
MD5 9f1b9212c3164406adf0f59c717540ab
BLAKE2b-256 ddebfd8d3ab0f2d6bf82ac0a4be04d5f00741d7949749e439ffedf3c63437c15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9a4985d1a1f14c728db509ce687d0e1c141ac7c6da24910b0ef7f19d4749f8b6
MD5 594991b0d4c27443d7ff437bab95ea30
BLAKE2b-256 26de4929a7ab0c8c82feca9f79713d94e481e710a146a9b9ef973e431fcd51e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 daaac310c9b88b14859923d19bb1a91ebb3e750529dfa907ef4312c66bf574b3
MD5 7651b8588ca9b852d458112e13dd0d88
BLAKE2b-256 5bb9cb24d8ba2393e331e1753fe8d88cac71f9fbee82568c31b8ea4b5d771ef4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6c9f8d663298d2c754dd43b6d5ca29cfaa487ae72b868e5c856c4a9dabd9f087
MD5 a8ebd4f2741896242bbe6bb5fe934c80
BLAKE2b-256 10e4bdb2e78581d36f8cc3254ef0d63667ab95954e4f4dc24150b9ba8d13e9b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5ab407c2745d8b73756849d8a948f76fb7adc0ff8f273d425de7fcdd378d59ad
MD5 6931140fdeeabf8a616b833f0dbe5c39
BLAKE2b-256 3a76584f4ff8d3511776d59af24fc7df447617dbb4d9455754bb74e56908dbc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp37-cp37m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 27065cc67a5eee1af6b79fe23e094d8f8228ff8a895cae057581e7d0bbca3562
MD5 a5eab71a30b93e10b49c8361c22e7096
BLAKE2b-256 e81526dd439cb047258fe152e58021331f5fe51f955bdf5f3b7c6994336b60ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6d287e6ccc261429dba5383178a228cf754766170632af0bd56b22e2d012291d
MD5 857ec65abe57ac3a586ea5d30517bf47
BLAKE2b-256 8e6cba39aa828823e5412b801dd251959a57007bdfb9341832143bed39812929

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 fd83188fc0f6ac2575233e67f8867e404763a75cd3ab70c94d48250f0c72ebae
MD5 b987021ceb72a0e2109b94e41d2b5e2e
BLAKE2b-256 83e8e3ab9a3cc985b67afbd84cb76b9fdbb74a570eff117a7cce1a5403fe3af8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 04570ddbbebcadcb1458cce10934bbdf16ed9936089e5c3ceac7eef6f8e418c1
MD5 a47f4920581867f4216d13c22ee280a8
BLAKE2b-256 f188e7eb1db7e67287583d18d2063fb4ce5631a59f8bf31db2a4331dede7c48b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b4b13005aa305c959637812d3d78106414780046bd2de8da6b26d24b21be06d8
MD5 9406ad23e5684cec06fe89c23f3569cc
BLAKE2b-256 a16b33f62b6d1af27a1097c9db0157ec96436d7a36add38d94a7da2e395af1bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp36-cp36m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 ce1ce8b392910f878e7714d0c3c0dc7d06f6e8cbece4ed3feb617fb4ba5ea741
MD5 5746a5222993407b9e95bf9dc804db86
BLAKE2b-256 0230506fc7f5a904754f43b4a976b451efd8c46e03a49a3a01539ee76bb00c1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c5e5b7c2e5ee0f6adcd076771cd971bef2f1f6c2602089b766928642a8fc0e75
MD5 55cf1a32bf745e1da88fa35d9c04b45b
BLAKE2b-256 3b30bff4d3df65a77e0408f4bee543661736a03fae76eb2afff632f903877339

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6.7

File hashes

Hashes for KDEpy-1.0.6-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 df2862eed23af607a93b9f52da7cab8d785e9702f0683187f99178c7410183dd
MD5 f0227890c06dc862526d2f2921b3d76a
BLAKE2b-256 3d2a68385c90dddbbb611698fab9befb33683f6e00322c94fdaac114f3ea48a3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.6-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.6-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5d75f97d764b4f1bbb5ed96be040066f4e7b9e9d3d77e9324ad9e116d1e74542
MD5 9d5981d9e55344dd6d8541d9afbb662a
BLAKE2b-256 f3f4b890afc2f1ce0023317cfd6fcfc73f4e0730a88e90e4cf989e928472da1b

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