Comments (2)
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.
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)
- python3.11 compatibility
- Citation for your implementation HOT 2
- Add a JIT compiler? (feature request) HOT 1
- Including KDEpy in BSD licensed project HOT 4
- Some problems HOT 1
- Is it possible to fit and save the state of the FFTKDE? HOT 4
- Can `bw_selection.py` return a value when root finding did not converge? HOT 1
- Installing CytoPy HOT 1
- how to get pseudo-uniform samples HOT 1
- Unable to solve for support numerically. HOT 2
- cutils compiles to package parent directory HOT 2
- Remove matplotlib dependency HOT 1
- Change build action to not automatically publish to PyPI? HOT 12
- Docs failing HOT 1
- Using bandwidth matrices for bivariate FFTKDE HOT 1
- SPherical KDE HOT 1
- kde.evaluate for density plot HOT 1
- Calculate corresponding quantities HOT 1
- Add a new rule of thumb HOT 2
- FutureWarning HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kdepy.