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

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8

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

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

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

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7m

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

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

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

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

KDEpy-1.0.9-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.9-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9286594b7b8ec95b9b3b4ec8176de8a2235674a3c23b85ddb31779772aa3e424
MD5 2461c5e7ac11540e0c0d1fc9102eae1a
BLAKE2b-256 11e62250449934e921e4d0ff9f09dfb107db6f95a6b698d6fa54a9a7a569ef3c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp38-cp38-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 1cb2af7aa3f6cb0abbf41aa98f0c84e61c7dd9488ce37c463e793946e2c6b9a9
MD5 e25273254cef1a3fd05d2d0efab99506
BLAKE2b-256 131bb41aa631f05686f29149c6d533bc871103ac782aeb845f7f63695869366c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2245a31547484a0543b3cdcca9f51ba637774723604578848594800379ec2b95
MD5 c4de228ab6a1c261fa6ee60b7773e619
BLAKE2b-256 d4e0066afe098eeebae1bd587c4d79dea289c9c126978a639871c0b06a65d3cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 71e0a6ad7eb7201236326e67f5fed2ddfb7e568091ed5bf517c6b14c114d4bf0
MD5 c2e19822a6162ad375b10cd2a75de4cd
BLAKE2b-256 467a57cf8671b6e56b276754888c0039bf49238f84af4efa6902b21db217b17a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7e17fe13dc8a4377fd99862ff1bbc01c6670adb5cbae49cdcbff21913d2121fc
MD5 819ad585d678e2c31b14c334dfdd95d2
BLAKE2b-256 f2d26241712f4dbe3d70c7073a9c945b9875e5acef476275aa088bfc547d6a8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 55df4a10dbcf62bf9952ad542ae63867659d4d64f25f8742eb0ca7d2e7bc1f11
MD5 48eebdb567ac2e3db3b8455d079962b4
BLAKE2b-256 099042a32dd502a9eb7864dd0aefdb91be367a74ce59c37f022eec1542c1c4ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp37-cp37m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 d48e255569cb123bab630c8f3be5e476ba5051601305ae7d983991ba2febcdc1
MD5 d17966c7326545d523f2900eb36dead8
BLAKE2b-256 f4f2b511bf090e83743a1c33d94ba2d5bb30b5fc1b5e525a08f89a512d86b444

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 dfda5e2e311409d06fa90f2a1c73c99247bfd9b463e722744a6bef6ccefd8c20
MD5 85517248c2dfcf7b8b0a596db51524e3
BLAKE2b-256 188adf2194a81643dcfad3f7a7b3fd4b2616eb53e2758197810b00991594685f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 3b345b22a5a521ef253090b7b5901bea86c0462ef4baf1347e26229433656754
MD5 0abd566e5af456b1e527fce3811d1f83
BLAKE2b-256 54caf2217a314841135932ad3c58c6ac8231968dae74c2a8fe3b65860f3f131d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 202f855083863550dba651d04babfc2f2760ba5bcb20cf9629f1455999686e7d
MD5 d0c21712612d8f80bc82ac448c9aa6bc
BLAKE2b-256 4d00545244cedd0a2110f333527262f0f313ce860ca7eeb6d19db7adc55f94fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0c1f27bf8489af9c6e8da51c19882be82ff5a950b90bbf3afd95faf7f62f88f5
MD5 ddad12815e97a419a0d6b74062afd4dc
BLAKE2b-256 07aca1d9d6877d0defb3df0fe5286e7345dcbe94cbb8b166ac54e8ac7b9dd71f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp36-cp36m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 8fcbb172f9ac59b1a8f96d6f5b5c82dda8bae67edd00d1acd20554df6a644307
MD5 9d4d628a594a28a897486d38d37d248b
BLAKE2b-256 4ad99ef1cdf2bdc152cf20686164e76cd6b3647f8bb004f870f020f3af1df519

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bb9856cccc095d6c947ed2bcf5e2a88e0f0f226924c97d99b937515e0e13a887
MD5 aac1ca17d48615c05ee453e09e903431
BLAKE2b-256 8fec9d08ec118e0098a44286e2e73bdc4620c28e8020d48269b0334259030f9f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 442960013ffeb49086a3d2ab7d7b45be0072f6191de05b62c3a82399436c5da5
MD5 4530f5bffa1703b17a80f498a46d408b
BLAKE2b-256 50177b3f50e0751da2773b25b1d73204cf32df71884d07118c6eb717061b9dee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.9-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.9-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c6d78cf3e8b4c1488e82b3b849bcae61cbed7fc352bbbb0dc107283d0b2e3ca4
MD5 9eabd0d818273f825cdf426b232aa828
BLAKE2b-256 eab23ddf596836f7eca728ae2e86c863d34903d2e9ddac226f9614b2baa7175c

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