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

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8

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

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

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

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7m

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

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

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

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

KDEpy-1.0.8-cp36-cp36m-manylinux1_x86_64.whl (396.5 kB view details)

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

KDEpy-1.0.8-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.8-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 39b308f612667e90e59d7c57bf72de129e77e902109c01e750b9238d003fa9b9
MD5 9c88de957c13f0eb276a46501b411739
BLAKE2b-256 bc3b937d8a57499f1a3981f13e590911fe92afdd61de1eb70174ab8eceec44e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp38-cp38-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 c2df8e89049d95c07153514cf8e0209e2682ec9e362fc4bc446ec9f197960f7e
MD5 e4e15709ec66884c71db369a2a262f4e
BLAKE2b-256 f99a5790c4dba9d7b0ef427ddebcfd86e8bdea3a7a8bf9d564bbe344c8ce756a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3253e615aba8c6091a21a4c1a702a11635c84b6fc8a694c13ea0d6fa94602d50
MD5 1b7164499c32ef2091169dcba53659d4
BLAKE2b-256 9a3f15a17bf48e152486d9b177032c777af10db10f02d550763ff0eda94e1b70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 176fb925f8d9238a612497a2e8ea9c2bc32a5008a657815743f92f1afa8e293b
MD5 d1ebc87fe8d397a2411f642c3e28e07f
BLAKE2b-256 54eb754963852a8180bbafa5f71e5bd2bd87d2c166114f505d440ac0b9ddd144

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 706108a498c6942a05b83e7cc136ac4dc1a471d145f1c5475ab9819a743eca8d
MD5 a5760d7d501c35d8e5e27e4528791602
BLAKE2b-256 f33d84ce79ba8d6fae2f89f750fd5f03ca2a9673cfce76c269c67925aaeb94b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a0a54d8558e5e9afd2a32d55d71ab82f7bee7678ffda68b6ef2cab23b5837c05
MD5 e8c0099ede62dbd54a68b7859e1f5f5f
BLAKE2b-256 5e6df043851c21d965bb4e41b88243ad65ba935eea494cd1f35b81723ba688c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp37-cp37m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 395bb49671effa1f0a26f90cb7dd4f102b84f3d4fa2d9d9cb5604cb9b0db58cf
MD5 45467622a3e6390cc73819c4527d4afe
BLAKE2b-256 d3e465e0555970d6cd4ac30a256edb2931361a3437db3662da06a0759ce99f1d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 122d0632715f3d3887c7bb30446904023cce108cd1f6668a665b6b4d4dbf1846
MD5 82d95aa1b3ef918da9eb73c55897fe38
BLAKE2b-256 5fe58a2adb07df666a3a440a780ccef1ff489ba156bd7e0e43870ee9fa88fc06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 fb08bf173b0a6b529d009e2a9d46adb150c9ad77deab5f8209719087e55fe849
MD5 3c7747c430cabf75136cfa2034080ea1
BLAKE2b-256 1060ba969913d4337e61006f3a201d75ab81ab9b4efc9961be8bc5f404098608

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 54fc5dfe56edb631605efb33e7da46346b4eb06ab45f18da11855f5d80187698
MD5 3797a83a21832224a368e37529136843
BLAKE2b-256 ae9e0a70ab421304d03edf3eb5531bdcafd0411fe32f9f2dcb76e4953a66a0f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d392e54baa05fbc81bd0e4591dfd77156145acfa5a326913a709fda134a7e7f6
MD5 4ff287a3a54cb3315185c535e3ed0138
BLAKE2b-256 5d278b46ce3cb33107d7fb44d59215e4c06c056fee61fc917c2025a99737226c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp36-cp36m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 9fc9d93f9fa545a55b22cf5ce71e87b38e36697bb3b70f94a0ee01437df696cf
MD5 a0a8987f4b9c34026c9c843220cadd62
BLAKE2b-256 cba3a4fe0ee0a26191617cdba1434357eeaf6bc1c6fa2f029eaf3a72d7dff56c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 396.5 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.8-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fcd7d2b938197b5af49be5b2b0404000027d45c86cf7b70ee3768ef2226b9e99
MD5 514b87eb3bbb651421989419bba08cbd
BLAKE2b-256 4befed438c0017a1ba24517fe441820d05ac24aa043f19b33f5d750007e656ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 016d8123c97d1af7a31218a287551348dd64cf43788bead0ff1954c7ea5eaad5
MD5 9f7b0167b5ee99b06d8cfecd56b860c7
BLAKE2b-256 2f24339bc2a0898b7bd0f2b3f5bbbb60733b73a62c18f8b87c56ea8d590658d7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: KDEpy-1.0.8-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.8-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b0682c3319f5b96825e1665a1a326ad7c5f98a16ff5208f2fd1ac5304a4e2bd4
MD5 ad60c0bdd7adfe1f345e39133a0accb8
BLAKE2b-256 20f7ec92f49fbe0a889399abe515738cad7b5e2922ed770db3a037d8db68dbfd

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