Giter Club home page Giter Club logo

Comments (2)

tommyod avatar tommyod commented on June 15, 2024 1

I would like to determine the KDE for each point of my data.

FFTKDE is much faster than scipy, but it's because of a gradeoff in the implementation. From the FFTKDE docs:

This class implements a convolution (FFT) based computation of a KDE. While this implementation is very fast, there are some limitations: (1) the bandwidth must be constant, (2) the KDE must be evaluated on an equidistant grid and (3) the grid must encompass every data point. The finer the grid, the smaller the error.

You can increase the number of grid points, or use a custom grid (but it must be equidistant). See the documentation of the .evaluate() method.

Something like this should do the trick:

grid_points = [64, 128] # 64 grid points in first dimension, 128 in second
out = FFTKDE(kernel="gaussian").fit(customer_2d).evaluate(grid_points)

grid_points = 64 # 64 grid points in both dimensions
out = FFTKDE(kernel="gaussian").fit(customer_2d).evaluate(grid_points)

For almost every practical purpose (e.g. plotting), 1024 grid points should be more than enough and the fact that the grid is equidistant does not matter. 1024 was chosen as the default because a monitor is often 1080 pixels wide, so even a full-screen plot of a KDE will have negligible error due to grid point interpolation. Again, this is for most use cases :)

Let me know if you have any other questions. The TreeKDE allows arbitrary grid points, but is not as fast as FFTKDE.

from kdepy.

suzannejin avatar suzannejin commented on June 15, 2024

This is very useful. Thank you for the quick response : )

I would like to determine the KDE for each point of my data.

FFTKDE is much faster than scipy, but it's because of a gradeoff in the implementation. From the FFTKDE docs:

This class implements a convolution (FFT) based computation of a KDE. While this implementation is very fast, there are some limitations: (1) the bandwidth must be constant, (2) the KDE must be evaluated on an equidistant grid and (3) the grid must encompass every data point. The finer the grid, the smaller the error.

You can increase the number of grid points, or use a custom grid (but it must be equidistant). See the documentation of the .evaluate() method.

Something like this should do the trick:

grid_points = [64, 128] # 64 grid points in first dimension, 128 in second
out = FFTKDE(kernel="gaussian").fit(customer_2d).evaluate(grid_points)

grid_points = 64 # 64 grid points in both dimensions
out = FFTKDE(kernel="gaussian").fit(customer_2d).evaluate(grid_points)

For almost every practical purpose (e.g. plotting), 1024 grid points should be more than enough and the fact that the grid is equidistant does not matter. 1024 was chosen as the default because a monitor is often 1080 pixels wide, so even a full-screen plot of a KDE will have negligible error due to grid point interpolation. Again, this is for most use cases :)

Let me know if you have any other questions. The TreeKDE allows arbitrary grid points, but is not as fast as FFTKDE.

from kdepy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.