I would like to have suggestions for packages that provide K-Nearest Neighbor density estimator, I've already searched the web (to not bother you guys with my question :) ), but most results were about kernel density estimator. I know that the both are theoretically related, but I'm looking for something which more specified for KNN (that uses the original formulas of KNN density estimate).

Note that R language packages more preferred, but don't mind Python.

Thanks in Advance :D


1 Answer 1


See this earlier inquiry: https://stackoverflow.com/questions/5840983/knn-density-estimation-r

Also, the knnde function from the SC19057 package is pretty straightforward and is specifically for density estimation. It just requires the R package 'FNN'. You can see the MAN page at https://rdrr.io/github/SC19057/Rpackage/man/knnde.html, and see if it gets you what you need.

For Python, have a look at scikit-learn library. This section of the man pages covers density estimation with sklearn: https://scikit-learn.org/stable/modules/density.html


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.