|
|
# Kernel Density Estimation
|
|
|
|
|
|
An implementation of kernel density estimation with dual-tree algorithms. Given a set of reference points and query points and a kernel function, this can estimate the density function at the location of each query point using trees.
|
|
|
|
|
|
# Available Predicates
|
|
|
|
|
|
* [initAndBuildModel/14](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#initandbuildmodel14)
|
|
|
* [evaluateWithQuery/5](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#evaluatewithquery5)
|
|
|
* [evaluateNoQuery/2](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#evaluatenoquery2)
|
|
|
|
|
|
---
|
|
|
|
|
|
[links/resources](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#connected-linksresources)
|
|
|
|
|
|
## **_initAndBuildModel/14_**
|
|
|
|
|
|
Build the KDE model with the given parameters and then trains it with the given reference data.
|
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
initAndBuildModel( +float32, +float32, +float32,
|
|
|
+string, +string, +string,
|
|
|
+integer,
|
|
|
+float32, +integer, +float32, +float32,
|
|
|
+pointer(float_array), +integer, +integer).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
|
|
| Name | Type | Description | Default |
|
|
|
|------|------|-------------|---------|
|
|
|
| bandwidth | +float | Bandwidth of the kernel. | 1.0 |
|
|
|
| relError | +float | Relative error tolerance for the prediction. | 0.05 |
|
|
|
| absError | +float | Absolute error tolerance for the prediction. | 0.0 |
|
|
|
| kernelType | +string | Kernel to use for the prediction.(‘gaussian’, ‘epanechnikov’, ‘laplacian’, ‘spherical’, ‘triangular’). | gaussian |
|
|
|
| treeType | +string | Tree to use for the prediction.(‘kd-tree’, ‘ball-tree’, ‘cover-tree’, ‘octree’, ‘r-tree’). | kd-tree |
|
|
|
| algorithm | +string | Algorithm to use for the prediction.(‘dual-tree’, ‘single-tree’). | dual-tree |
|
|
|
| monteCarlo | +integer(bool) | Whether to use Monte Carlo estimations when possible. | (0)false |
|
|
|
| mcProb | +float | Probability of the estimation being bounded by relative error when using Monte Carlo estimations. | 0.95 |
|
|
|
| initialSampleSize | +integer | | 100 |
|
|
|
| mcEntryCoef | +float | Controls how much larger does the amount of node descendants has to be compared to the initial sample size in order to be a candidate for Monte Carlo estimations. | 3.0 |
|
|
|
| mcBreakCoef | +float | Controls what fraction of the amount of node’s descendants is the limit for the sample size before it recurses. | 0.4 |
|
|
|
| referenceSet | +matrix | Input reference dataset use for KDE. | - |
|
|
|
|
|
|
---
|
|
|
|
|
|
## **_evaluateWithQuery/5_**
|
|
|
|
|
|
Perform kernel density estimation on the given query set.
|
|
|
|
|
|
**_initAndBuildModel/14_** has to be called before.
|
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
evaluateWithQuery( +pointer(float_array), +integer, +integer,
|
|
|
-pointer(float_array), -integer).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
|
|
| Name | Type | Description | Default |
|
|
|
|------|------|-------------|---------|
|
|
|
| querySet | +matrix | Query dataset to KDE on. | - |
|
|
|
| estimations | -vector | Vector to store density predictions. | - |
|
|
|
|
|
|
---
|
|
|
|
|
|
## **_evaluateNoQuery/2_**
|
|
|
|
|
|
Perform kernel density estimation on the reference set.
|
|
|
|
|
|
If possible, it returns normalized estimations.
|
|
|
|
|
|
**_initAndBuildModel/14_** has to be called before.
|
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
evaluateNoQuery( -pointer(float_array), -integer).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
|
|
| Name | Type | Description | Default |
|
|
|
|------|------|-------------|---------|
|
|
|
| estimations | -vector | Vector to store density predictions. | - |
|
|
|
|
|
|
---
|
|
|
|
|
|
# Connected Links/Resources
|
|
|
|
|
|
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
|
|
|
|
|
|
* [MLpack::kde_C++\_documentation](https://www.mlpack.org/doc/stable/doxygen/classmlpack_1_1kde_1_1KDE.html)
|
|
|
* [MLpack::kde_Python_documentation](https://www.mlpack.org/doc/stable/python_documentation.html#kde)
|
|
|
|
|
|
added some of the links from the python documentation
|
|
|
|
|
|
* knn
|
|
|
* [Kernel density estimation on Wikipedia](https://en.wikipedia.org/wiki/Kernel_density_estimation)
|
|
|
* [Tree-Independent Dual-Tree Algorithms (pdf)](https://arxiv.org/pdf/1304.4327.pdf) |
|
|
\ No newline at end of file |