1mlpack_knn(1) User Commands mlpack_knn(1)
2
3
4
6 mlpack_knn - k-nearest-neighbors search
7
9 mlpack_knn [-a string] [-e double] [-m unknown] [-k int] [-l int] [-q string] [-R bool] [-r string] [-b double] [-s int] [-u double] [-t string] [-D string] [-T string] [-V bool] [-d string] [-n string] [-M unknown] [-h -v]
10
12 This program will calculate the k-nearest-neighbors of a set of points
13 using kd-trees or cover trees (cover tree support is experimental and
14 may be slow). You may specify a separate set of reference points and
15 query points, or just a reference set which will be used as both the
16 reference and query set.
17
18 For example, the following command will calculate the 5 nearest neigh‐
19 bors of each point in 'input.csv' and store the distances in 'dis‐
20 tances.csv' and the neighbors in 'neighbors.csv':
21
22 $ knn --k 5 --reference_file input.csv --neighbors_file neighbors.csv
23
24 The output files are organized such that row i and column j in the
25 neighbors output matrix corresponds to the index of the point in the
26 reference set which is the j'th nearest neighbor from the point in the
27 query set with index i. Row j and column i in the distances output
28 matrix corresponds to the distance between those two points.
29
31 --algorithm (-a) [string]
32 Type of neighbor search: 'naive', 'single_tree', 'dual_tree',
33 'greedy'. Default value 'dual_tree'.
34
35 --epsilon (-e) [double]
36 If specified, will do approximate nearest neighbor search with
37 given relative error. Default value 0.
38
39 --help (-h) [bool]
40 Default help info.
41
42 --info [string]
43 Get help on a specific module or option. Default value ''.
44
45 --input_model_file (-m) [unknown]
46 Pre-trained kNN model. Default value ''.
47
48 --k (-k) [int]
49 Number of nearest neighbors to find. Default value 0.
50
51 --leaf_size (-l) [int]
52 Leaf size for tree building (used for kd-trees, vp trees, random
53 projection trees, UB trees, R trees, R* trees, X trees, Hilbert
54 R trees, R+ trees, R++ trees, spill trees, and octrees).
55 Default value 20.
56
57 --query_file (-q) [string]
58 Matrix containing query points (optional). Default value ''.
59
60 --random_basis (-R) [bool]
61 Before tree-building, project the data onto a random orthogonal
62 basis.
63
64 --reference_file (-r) [string]
65 Matrix containing the reference dataset. Default value ''.
66
67 --rho (-b) [double]
68 Balance threshold (only valid for spill trees). Default value
69 0.7.
70
71 --seed (-s) [int]
72 Random seed (if 0, std::time(NULL) is used). Default value 0.
73
74 --tau (-u) [double]
75 Overlapping size (only valid for spill trees). Default value 0.
76
77 --tree_type (-t) [string]
78 Type of tree to use: 'kd', 'vp', 'rp', 'max-rp', 'ub', 'cover',
79 'r', 'r-star', 'x', 'ball', 'hilbert-r', 'r-plus', 'r-plus-
80 plus', 'spill', 'oct'. Default value 'kd'.
81
82 --true_distances_file (-D) [string]
83 Matrix of true distances to compute the effective error (average
84 relative error) (it is printed when -v is specified). Default
85 value ''.
86
87 --true_neighbors_file (-T) [string]
88 Matrix of true neighbors to compute the recall (it is printed
89 when -v is specified). Default value ''.
90
91 --verbose (-v) [bool]
92 Display informational messages and the full list of parameters
93 and timers at the end of execution.
94
95 --version (-V) [bool]
96 Display the version of mlpack.
97
99 --distances_file (-d) [string]
100 Matrix to output distances into. Default value ''.
101
102 --neighbors_file (-n) [string]
103 Matrix to output neighbors into. Default value ''.
104
105 --output_model_file (-M) [unknown]
106 If specified, the kNN model will be output here. Default value
107 ''.
108
110 For further information, including relevant papers, citations, and the‐
111 ory, consult the documentation found at http://www.mlpack.org or
112 included with your distribution of mlpack.
113
114
115
116mlpack-3.0.4 21 February 2019 mlpack_knn(1)