... | ... | @@ -2,6 +2,16 @@ |
|
|
|
|
|
An implementation of two strategies for furthest neighbor search. This can be used to compute the furthest neighbor of query point(s) from a set of points.
|
|
|
|
|
|
```prolog
|
|
|
:- use_module('path/to/.../src/methods/approx_kfn/approx_kfn.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],
|
|
|
initDrusillaModelWithTrain(TrainData, 3, 2, 2),
|
|
|
searchDrusilla(TestData, 3, 2, NeighborsList, _, DistancesList, _).
|
|
|
```
|
|
|
|
|
|
# Available Predicates
|
|
|
|
|
|
* [initDrusillaModelNoTrain/2](/PrologMethods/Geometry/approx_kfn#initdrusillamodelnotrain2)
|
... | ... | @@ -25,7 +35,12 @@ Initiates the DrusillaSearch Model but doesn’t train it. |
|
|
|
|
|
```prolog
|
|
|
%% part of the definition
|
|
|
initDrusillaModelNoTrain( +integer, +integer).
|
|
|
initDrusillaModelNoTrain(L, M) :-
|
|
|
L > 0,
|
|
|
M > 0,
|
|
|
initDrusillaModelNoTrainI(L, M).
|
|
|
|
|
|
foreign(initDrusillaModelNoTrain, c, initDrusillaModelNoTrainI(+integer, +integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -45,8 +60,14 @@ Afterwards **searchDrusilla** can be used. |
|
|
|
|
|
```prolog
|
|
|
%% part of the definition
|
|
|
initDrusillaModelWithTrain( +pointer(float_array), +integer, +integer,
|
|
|
+integer, +integer).
|
|
|
initDrusillaModelWithTrain(DataList, DataRows, L, M) :-
|
|
|
L > 0,
|
|
|
M > 0,
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrownum, X)),
|
|
|
initDrusillaModelWithTrainI(X, Xsize, Xrownum, L, M).
|
|
|
|
|
|
foreign(initDrusillaModelWithTrain, c, initDrusillaModelWithTrainI( +pointer(float_array), +integer, +integer,
|
|
|
+integer, +integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -65,10 +86,17 @@ Run Search on the given Queryset with the Drusilla Search Policy. |
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
searchDrusilla( +pointer(float_array), +integer, +integer,
|
|
|
searchDrusilla(DataList, DataRows, K, NeighborsList, YCols, DistancesList, ZCols) :-
|
|
|
K > 0,
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrownum, X)),
|
|
|
searchDrusillaI(X, Xsize, Xrownum, K, Y, YCols, YRows, Z, ZCols, ZRows),
|
|
|
convert_float_array_to_2d_list(Y, YCols, YRows, NeighborsList),
|
|
|
convert_float_array_to_2d_list(Z, ZCols, ZRows, DistancesList).
|
|
|
|
|
|
foreign(searchDrusilla, c, searchDrusillaI( +pointer(float_array), +integer, +integer,
|
|
|
+integer,
|
|
|
-pointer(float_array), -integer, -integer,
|
|
|
-pointer(float_array), -integer, -integer).
|
|
|
-pointer(float_array), -integer, -integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -88,8 +116,14 @@ Trains the DrusillaSearch Model with the given reference Set. |
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
trainDrusilla( +pointer(float_array), +integer, +integer,
|
|
|
+integer, +integer).
|
|
|
trainDrusilla(DataList, DataRows, L, M) :-
|
|
|
L > 0,
|
|
|
M > 0,
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrownum, X)),
|
|
|
trainDrusillaI(X, Xsize, Xrownum, L, M).
|
|
|
|
|
|
foreign(trainDrusilla, c, trainDrusillaI( +pointer(float_array), +integer, +integer,
|
|
|
+integer, +integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -110,7 +144,12 @@ Initiates the QDAFNSearch Model but doesn’t train it. |
|
|
|
|
|
```prolog
|
|
|
%% part of the definition
|
|
|
initQDAFNModelNoTrain( +integer, +integer).
|
|
|
initQDAFNModelNoTrain(L, M) :-
|
|
|
L > 0,
|
|
|
M > 0,
|
|
|
initQDAFNModelNoTrainI(L, M).
|
|
|
|
|
|
foreign(initQDAFNModelNoTrain, c, initQDAFNModelNoTrainI(+integer, +integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -130,8 +169,14 @@ Afterwards **searchQDAFN** can be used. |
|
|
|
|
|
```prolog
|
|
|
%% part of the definition
|
|
|
initQDAFNModelWithTrain( +pointer(float_array), +integer, +integer,
|
|
|
+integer, +integer).
|
|
|
initQDAFNModelWithTrain(DataList, DataRows, L, M) :-
|
|
|
L > 0,
|
|
|
M > 0,
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrownum, X)),
|
|
|
initQDAFNModelWithTrainI(X, Xsize, Xrownum, L, M).
|
|
|
|
|
|
foreign(initQDAFNModelWithTrain, c, initQDAFNModelWithTrainI( +pointer(float_array), +integer, +integer,
|
|
|
+integer, +integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -150,10 +195,17 @@ Run Search on the given Queryset with the QDAFN Search Policy. |
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
searchQDAFN( +pointer(float_array), +integer, +integer,
|
|
|
searchQDAFN(DataList, DataRows, K, NeighborsList, YCols, DistancesList, ZCols) :-
|
|
|
K > 0,
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrownum, X)),
|
|
|
searchQDAFNI(X, Xsize, Xrownum, K, Y, YCols, YRows, Z, ZCols, ZRows),
|
|
|
convert_float_array_to_2d_list(Y, YCols, YRows, NeighborsList),
|
|
|
convert_float_array_to_2d_list(Z, ZCols, ZRows, DistancesList).
|
|
|
|
|
|
foreign(searchQDAFN, c, searchQDAFNI( +pointer(float_array), +integer, +integer,
|
|
|
+integer,
|
|
|
-pointer(float_array), -integer, -integer,
|
|
|
-pointer(float_array), -integer, -integer).
|
|
|
-pointer(float_array), -integer, -integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -173,8 +225,14 @@ Trains the QDAFNSearch Model with the given reference Set. |
|
|
|
|
|
```prolog
|
|
|
%% part of the predicate definition
|
|
|
trainQDAFN( +pointer(float_array), +integer, +integer,
|
|
|
+integer, +integer).
|
|
|
trainQDAFN(DataList, DataRows, L, M) :-
|
|
|
L > 0,
|
|
|
M > 0,
|
|
|
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrownum, X)),
|
|
|
trainQDAFNI(X, Xsize, Xrownum, L, M).
|
|
|
|
|
|
foreign(trainQDAFN, c, trainQDAFNI( +pointer(float_array), +integer, +integer,
|
|
|
+integer, +integer)).
|
|
|
```
|
|
|
|
|
|
### Parameters
|
... | ... | @@ -191,9 +249,9 @@ trainQDAFN( +pointer(float_array), +integer, +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::DrusillaSearch_C++\_documentation**](https://www.mlpack.org/doc/stable/doxygen/classmlpack_1_1neighbor_1_1DrusillaSelect.html)
|
|
|
* [**MLpack::QDAFN_C++\_documentation**](https://www.mlpack.org/doc/stable/doxygen/classmlpack_1_1neighbor_1_1QDAFN.html)
|
|
|
* [**MLpack::Approx_KFN_Python_documentation**](https://www.mlpack.org/doc/stable/python_documentation.html#approx_kfn)
|
|
|
* [**MLpack::DrusillaSearch_C++\_documentation**](https://www.mlpack.org/doc/mlpack-3.4.2/doxygen/classmlpack_1_1neighbor_1_1DrusillaSelect.html)
|
|
|
* [**MLpack::QDAFN_C++\_documentation**](https://www.mlpack.org/doc/mlpack-3.4.2/doxygen/classmlpack_1_1neighbor_1_1QDAFN.html)
|
|
|
* [**MLpack::Approx_KFN_Python_documentation**](https://www.mlpack.org/doc/mlpack-3.4.2/python_documentation.html#approx_kfn)
|
|
|
|
|
|
added some of the links from the python documentation
|
|
|
|
... | ... | |