Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase speed for large data sets #2

Open
LKremer opened this issue Sep 5, 2019 · 6 comments
Open

Increase speed for large data sets #2

LKremer opened this issue Sep 5, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@LKremer
Copy link
Owner

LKremer commented Sep 5, 2019

When plotting millions of points, counting the number of neighbors of each point is extremely slow. The current algorithm calculates the pairwise distance for all points. This could be optimized, for instance with this approach. Other ideas are welcome.

@LKremer LKremer added the enhancement New feature or request label Sep 5, 2019
@LKremer LKremer self-assigned this Sep 5, 2019
@seasmith
Copy link

seasmith commented Sep 6, 2019

Have you seen the RANN package?

I don't know too much about it but I know nngeo uses RANN to implement nearest-neighbors.

@LKremer
Copy link
Owner Author

LKremer commented Sep 6, 2019

Haven't tried this exact package yet, but I tried dbscan::pointdensity which also uses the same C++ library (ANN). It's roughly twice as fast when plotting ~100k points. I'm currently testing it.

@LKremer
Copy link
Owner Author

LKremer commented Sep 20, 2019

I added method="kde2d"to the geom and stat. It is indeed faster for many points (~ >20k) but slower for few points.

@olechnwin
Copy link

How do you use the kde2d method? I've downloaded the latest version of this package from github but geom_pointdensity still do not have method parameter?

@LKremer
Copy link
Owner Author

LKremer commented Feb 21, 2020

Hi @olechnwin,
you just use geom_pointdensity(method ="kde2d") and it should work. Maybe you still have an old version of the package loaded, or the old version is somehow still installed on your system? You could try restarting your R session, then explicitly uninstalling the old version and then reinstalling the GitHub version

@Aariq
Copy link

Aariq commented Feb 9, 2024

I've been testing some alternatives because MASS::kde2d runs out of memory with the dataset I'm working with. So far I've tried:

MASSExtra::kde_2d(): seems faster, promises to scale better, but still runs out of memory
KernSmoth::bkde2D(): works, and pretty fast too. Requires a larger than default gridsize and errors unless I increase it.

Some other options are summarized in this (in progress?) paper: https://vita.had.co.nz/papers/density-estimation.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants