... | @@ -2,27 +2,49 @@ |
... | @@ -2,27 +2,49 @@ |
|
|
|
|
|
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.
|
|
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.
|
|
|
|
|
|
|
|
```prolog
|
|
|
|
:- use_module('path/to/.../src/methods/kde/kde.pl').
|
|
|
|
|
|
|
|
%% usage example
|
|
|
|
TrainData = [5.1,3.5,1.4, 4.9,3.0,1.4, 4.7,3.2,1.3, 4.6,3.1,1.5],
|
|
|
|
TestData = [3,2,0, 5,1,4, 0,0,4, 3,3,5, 0,5,5, 2,5,5],
|
|
|
|
kde_initAndBuildModel(1.0, 0.05, 0.0, gaussian, kd_tree, dual_tree, 0, 0.95, 100, 3.0, 0.4, TrainData, 3),
|
|
|
|
kde_evaluateWithQuery(TestData, 3, Estimation).
|
|
|
|
```
|
|
|
|
|
|
# Available Predicates
|
|
# Available Predicates
|
|
|
|
|
|
* [initAndBuildModel/14](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#initandbuildmodel14)
|
|
* [kde_initAndBuildModel/13](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#kde_initandbuildmodel13)
|
|
* [evaluateWithQuery/5](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#evaluatewithquery5)
|
|
* [kde_evaluateWithQuery/3](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#kde_evaluatewithquery3)
|
|
* [evaluateNoQuery/2](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#evaluatenoquery2)
|
|
* [kde_evaluateNoQuery/1](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#kde_evaluatenoquery1)
|
|
|
|
|
|
---
|
|
---
|
|
|
|
|
|
[links/resources](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#connected-linksresources)
|
|
[links/resources](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Misc.-other/kde#connected-linksresources)
|
|
|
|
|
|
## **_initAndBuildModel/14_**
|
|
## **_kde_initAndBuildModel/13_**
|
|
|
|
|
|
Build the KDE model with the given parameters and then trains it with the given reference data.
|
|
Build the KDE model with the given parameters and then trains it with the given reference data.
|
|
|
|
|
|
```prolog
|
|
```prolog
|
|
%% part of the predicate definition
|
|
%% predicate definition
|
|
initAndBuildModel( +float32, +float32, +float32,
|
|
kde_initAndBuildModel(Bandwidth, RelError, AbsError, KernelType, TreeType, Algorithm, MonteCarlo, McProb, InitialSampleSize, MCEntryCoef, MCBreakCoef, DataList, DataRows) :-
|
|
|
|
Bandwidth > 0.0,
|
|
|
|
RelError >= 0.0, RelError =< 1.0,
|
|
|
|
AbsError >= 0.0,
|
|
|
|
McProb >= 0.0, McProb < 1.0,
|
|
|
|
InitialSampleSize > 0,
|
|
|
|
MCEntryCoef >= 1,
|
|
|
|
MCBreakCoef > 0.0, MCBreakCoef =< 1.0,
|
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrownum, X)),
|
|
|
|
initAndBuildModelI(Bandwidth, RelError, AbsError, KernelType, TreeType, Algorithm, MonteCarlo, McProb, InitialSampleSize, MCEntryCoef, MCBreakCoef, X, Xsize, Xrownum).
|
|
|
|
|
|
|
|
%% foreign c++ predicate definition
|
|
|
|
foreign(initAndBuildModel, c, initAndBuildModelI( +float32, +float32, +float32,
|
|
+string, +string, +string,
|
|
+string, +string, +string,
|
|
+integer,
|
|
+integer,
|
|
+float32, +integer, +float32, +float32,
|
|
+float32, +integer, +float32, +float32,
|
|
+pointer(float_array), +integer, +integer).
|
|
+pointer(float_array), +integer, +integer)).
|
|
```
|
|
```
|
|
|
|
|
|
### Parameters
|
|
### Parameters
|
... | @@ -43,16 +65,22 @@ initAndBuildModel( +float32, +float32, +float32, |
... | @@ -43,16 +65,22 @@ initAndBuildModel( +float32, +float32, +float32, |
|
|
|
|
|
---
|
|
---
|
|
|
|
|
|
## **_evaluateWithQuery/5_**
|
|
## **_kde_evaluateWithQuery/3_**
|
|
|
|
|
|
Perform kernel density estimation on the given query set.
|
|
Perform kernel density estimation on the given query set.
|
|
|
|
|
|
**_initAndBuildModel/14_** has to be called before.
|
|
**_kde_initAndBuildModel/13_** has to be called before.
|
|
|
|
|
|
```prolog
|
|
```prolog
|
|
%% part of the predicate definition
|
|
%% predicate definition
|
|
evaluateWithQuery( +pointer(float_array), +integer, +integer,
|
|
kde_evaluateWithQuery(QueryList, QueryRows, EstimationList) :-
|
|
-pointer(float_array), -integer).
|
|
convert_list_to_float_array(QueryList, QueryRows, array(Xsize, Xrownum, X)),
|
|
|
|
evaluateWithQueryI(X, Xsize, Xrownum, Y, Ysize),
|
|
|
|
convert_float_array_to_list(Y, Ysize, EstimationList).
|
|
|
|
|
|
|
|
%% foreign c++ predicate definition
|
|
|
|
foreign(evaluateWithQuery, c, evaluateWithQueryI( +pointer(float_array), +integer, +integer,
|
|
|
|
-pointer(float_array), -integer)).
|
|
```
|
|
```
|
|
|
|
|
|
### Parameters
|
|
### Parameters
|
... | @@ -63,17 +91,22 @@ evaluateWithQuery( +pointer(float_array), +integer, +integer, |
... | @@ -63,17 +91,22 @@ evaluateWithQuery( +pointer(float_array), +integer, +integer, |
|
|
|
|
|
---
|
|
---
|
|
|
|
|
|
## **_evaluateNoQuery/2_**
|
|
## **_kde_evaluateNoQuery/1_**
|
|
|
|
|
|
Perform kernel density estimation on the reference set.
|
|
Perform kernel density estimation on the reference set.
|
|
|
|
|
|
If possible, it returns normalized estimations.
|
|
If possible, it returns normalized estimations.
|
|
|
|
|
|
**_initAndBuildModel/14_** has to be called before.
|
|
**_kde_initAndBuildModel/13_** has to be called before.
|
|
|
|
|
|
```prolog
|
|
```prolog
|
|
%% part of the predicate definition
|
|
%% predicate definition
|
|
evaluateNoQuery( -pointer(float_array), -integer).
|
|
kde_evaluateNoQuery(EstimationList) :-
|
|
|
|
evaluateNoQueryI(Y, Ysize),
|
|
|
|
convert_float_array_to_list(Y, Ysize, EstimationList).
|
|
|
|
|
|
|
|
%% foreign c++ predicate definition
|
|
|
|
foreign(evaluateNoQuery, c, evaluateNoQueryI(-pointer(float_array), -integer)).
|
|
```
|
|
```
|
|
|
|
|
|
### Parameters
|
|
### Parameters
|
... | @@ -87,8 +120,8 @@ evaluateNoQuery( -pointer(float_array), -integer). |
... | @@ -87,8 +120,8 @@ evaluateNoQuery( -pointer(float_array), -integer). |
|
|
|
|
|
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.
|
|
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_C++\_documentation**](https://www.mlpack.org/doc/mlpack-3.4.2/doxygen/classmlpack_1_1kde_1_1KDE.html)
|
|
* [**MLpack::kde_Python_documentation**](https://www.mlpack.org/doc/stable/python_documentation.html#kde)
|
|
* [**MLpack::kde_Python_documentation**](https://www.mlpack.org/doc/mlpack-3.4.2/python_documentation.html#kde)
|
|
|
|
|
|
added some of the links from the python documentation
|
|
added some of the links from the python documentation
|
|
|
|
|
... | | ... | |