|
|
# Fast Max-Kernel Search
|
|
|
|
|
|
An implementation of the single-tree and dual-tree fast max-kernel search (FastMKS) algorithm. Given a set of reference points and a set of query points, this can find the reference point with maximum kernel value for each query point
|
|
|
An implementation of the single-tree and dual-tree fast max-kernel search (FastMKS) algorithm. Given a set of reference points and a set of query points, this can find the reference point with maximum kernel value for each query point.
|
|
|
|
|
|
```prolog
|
|
|
:- use_module('path/to/.../src/methods/fastmks/fastmks.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],
|
|
|
fastmks_initModel(TrainData, 3, linear, 0.0, 0.0, 1.0, 0.0, 0, 0, 1.2),
|
|
|
fastmks_searchWithQuery(TestData, 4, 2, IndicesList, _, KernelsList, _, 1.1).
|
|
|
```
|
|
|
|
|
|
# Available Predicates
|
|
|
|
|
|
* [initModel/11](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Geometry/fastmks#initmodel11)
|
|
|
* [searchWithQuery/11](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Geometry/fastmks#searchwithquery11)
|
|
|
* [searchNoQuery/7](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Geometry/fastmks#searchnoquery7)
|
|
|
* [fastmks_initModel/10](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Geometry/fastmks#fastmks_initmodel10)
|
|
|
* [fastmks_searchWithQuery/8](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Geometry/fastmks#fastmks_searchwithquery8)
|
|
|
* [fastmks_searchNoQuery/5](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Geometry/fastmks#fastmks_searchnoquery5)
|
|
|
|
|
|
---
|
|
|
|
|
|
[links/resources](https://gitlab.cs.uni-duesseldorf.de/stups/abschlussarbeiten/prolog-mlpack-libary/-/wikis/PrologMethods/Geometry/fastmks#connected-linksresources)
|
|
|
|
|
|
## **_initModel/11_**
|
|
|
## **_fastmks_initModel/10_**
|
|
|
|
|
|
Initializes the model on the given reference set.
|
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
initModel( +pointer(float_array), +integer, +integer,
|
|
|
%% predicate definition
|
|
|
fastmks_initModel(DataList, DataRows, Kernel, Degree, Offset, Bandwidth, Scale, SingleMode, Naive, Base) :-
|
|
|
Base > 1.0,
|
|
|
Bandwidth > 0.0,
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrows, X)),
|
|
|
initModelI(X, Xsize, Xrows, Kernel, Degree, Offset, Bandwidth, Scale, SingleMode, Naive, Base).
|
|
|
|
|
|
%% foreign c++ predicate definition
|
|
|
foreign(initModel, c, initModelI( +pointer(float_array), +integer, +integer,
|
|
|
+string,
|
|
|
+float32, +float32, +float32, +float32,
|
|
|
+integer, +integer,
|
|
|
+float32).
|
|
|
+float32)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -40,17 +57,26 @@ initModel( +pointer(float_array), +integer, +integer, |
|
|
|
|
|
---
|
|
|
|
|
|
## **_searchWithQuery/11_**
|
|
|
## **_fastmks_searchWithQuery/8_**
|
|
|
|
|
|
Search with a different query set.
|
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
searchWithQuery( +pointer(float_array), +integer, +integer,
|
|
|
%% predicate definition
|
|
|
fastmks_searchWithQuery(DataList, DataRows, K, IndicesList, YCols, KernelsList, ZCols, Base) :-
|
|
|
K > 0,
|
|
|
Base > 1.0,
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrows, X)),
|
|
|
searchWithQueryI(X, Xsize, Xrows, K, Y, YCols, YRows, Z, ZCols, ZRows, Base),
|
|
|
convert_float_array_to_2d_list(Y, YCols, YRows, IndicesList),
|
|
|
convert_float_array_to_2d_list(Z, ZCols, ZRows, KernelsList).
|
|
|
|
|
|
%% foreign c++ predicate definition
|
|
|
foreign(searchWithQuery, c, searchWithQueryI( +pointer(float_array), +integer, +integer,
|
|
|
+integer,
|
|
|
-pointer(float_array), -integer, -integer,
|
|
|
-pointer(float_array), -integer, -integer,
|
|
|
+float32).
|
|
|
+float32)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -64,15 +90,22 @@ searchWithQuery( +pointer(float_array), +integer, +integer, |
|
|
|
|
|
---
|
|
|
|
|
|
## **_searchNoQuery/7_**
|
|
|
## **_fastmks_searchNoQuery/5_**
|
|
|
|
|
|
Search with the reference set as the query set.
|
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
searchNoQuery( +integer,
|
|
|
%% predicate definition
|
|
|
fastmks_searchNoQuery(K, IndicesList, YCols, KernelsList, ZCols) :-
|
|
|
K > 0,
|
|
|
searchNoQueryI(K, Y, YCols, YRows, Z, ZCols, ZRows),
|
|
|
convert_float_array_to_2d_list(Y, YCols, YRows, IndicesList),
|
|
|
convert_float_array_to_2d_list(Z, ZCols, ZRows, KernelsList).
|
|
|
|
|
|
%% foreign c++ predicate definition
|
|
|
foreign(searchNoQuery, c, searchNoQueryI( +integer,
|
|
|
-pointer(float_array), -integer, -integer,
|
|
|
-pointer(float_array), -integer, -integer)
|
|
|
-pointer(float_array), -integer, -integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -88,8 +121,8 @@ searchNoQuery( +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.
|
|
|
|
|
|
* [**MLpack::fastmks_C++\_documentation**](https://www.mlpack.org/doc/stable/doxygen/classmlpack_1_1fastmks_1_1FastMKS.html)
|
|
|
* [**MLpack::fastmks_Python_documentation**](https://www.mlpack.org/doc/stable/python_documentation.html#fastmks)
|
|
|
* [**MLpack::fastmks_C++\_documentation**](https://www.mlpack.org/doc/mlpack-3.4.2/doxygen/classmlpack_1_1fastmks_1_1FastMKS.html)
|
|
|
* [**MLpack::fastmks_Python_documentation**](https://www.mlpack.org/doc/mlpack-3.4.2/python_documentation.html#fastmks)
|
|
|
|
|
|
added some of the links from the python documentation
|
|
|
|
... | ... | |