From a87e2fa7cb505dc2a80a54eb9eb3be99ddfd417f Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 31 Jan 2023 19:52:24 +0000 Subject: [PATCH] Documentation for a8af29bf6520d511b81850babb71f5e9d225d005 --- annotated.html | 20 +- annotated_dup.js | 7 +- classes.html | 27 +- d1/dbb/k__nearest__neighbors_8cpp__incl.map | 10 + d1/dbb/k__nearest__neighbors_8cpp__incl.md5 | 1 + d1/dbb/k__nearest__neighbors_8cpp__incl.svg | 127 +++++ d4/d3e/k__nearest__neighbors_8cpp.html | 366 +++++++++++++ d4/d3e/k__nearest__neighbors_8cpp.js | 7 + ...ddf1224851353fc92bfbff6f499fa97_cgraph.map | 5 + ...ddf1224851353fc92bfbff6f499fa97_cgraph.md5 | 1 + ...ddf1224851353fc92bfbff6f499fa97_cgraph.svg | 51 ++ ...8dca7b867074164d5f45b0f3851269d_cgraph.map | 4 + ...8dca7b867074164d5f45b0f3851269d_cgraph.md5 | 1 + ...8dca7b867074164d5f45b0f3851269d_cgraph.svg | 36 ++ ...6ae16e50bb153ebaa7251d0aaa97b69_cgraph.map | 10 + ...6ae16e50bb153ebaa7251d0aaa97b69_cgraph.md5 | 1 + ...6ae16e50bb153ebaa7251d0aaa97b69_cgraph.svg | 135 +++++ d5/d88/md__d_i_r_e_c_t_o_r_y.html | 1 + d7/d4c/namespacek__nearest__neighbors.html | 118 +++++ ...k__nearest__neighbors_1_1_knn-members.html | 124 +++++ d8/d77/namespacemachine__learning.html | 3 + ...ning_1_1k__nearest__neighbors_1_1_knn.html | 422 +++++++++++++++ ...arning_1_1k__nearest__neighbors_1_1_knn.js | 12 + ...2e152db014cd4de675fa906e5ef2861_cgraph.map | 16 + ...2e152db014cd4de675fa906e5ef2861_cgraph.md5 | 1 + ...2e152db014cd4de675fa906e5ef2861_cgraph.svg | 239 +++++++++ ...earest__neighbors_1_1_knn__coll__graph.map | 6 + ...earest__neighbors_1_1_knn__coll__graph.md5 | 1 + ...earest__neighbors_1_1_knn__coll__graph.svg | 71 +++ dir_3343723ae086de42ee4ca9774da3a13f.html | 3 + dir_3343723ae086de42ee4ca9774da3a13f.js | 1 + files.html | 11 +- functions_func_k.html | 1 + functions_func_o.html | 6 +- functions_func_p.html | 2 +- functions_func_u.html | 2 +- functions_func_~.html | 1 + functions_k.html | 1 + functions_o.html | 4 +- functions_p.html | 2 +- functions_u.html | 2 +- functions_vars.html | 2 + functions_x.html | 1 + functions_y.html | 1 + functions_~.html | 1 + globals_func_m.html | 2 +- globals_func_s.html | 2 +- globals_func_t.html | 2 +- globals_m.html | 2 +- globals_p.html | 2 +- globals_s.html | 2 +- globals_t.html | 2 +- hierarchy.html | 147 ++--- hierarchy.js | 5 +- inherit_graph_100.map | 2 +- inherit_graph_100.md5 | 2 +- inherit_graph_100.svg | 4 +- inherit_graph_101.map | 3 + inherit_graph_101.md5 | 1 + inherit_graph_101.svg | 21 + inherit_graph_54.map | 2 +- inherit_graph_54.md5 | 2 +- inherit_graph_54.svg | 12 +- inherit_graph_55.map | 2 +- inherit_graph_55.md5 | 2 +- inherit_graph_55.svg | 10 +- inherit_graph_56.map | 2 +- inherit_graph_56.md5 | 2 +- inherit_graph_56.svg | 12 +- inherit_graph_57.map | 2 +- inherit_graph_57.md5 | 2 +- inherit_graph_57.svg | 13 +- inherit_graph_58.map | 2 +- inherit_graph_58.md5 | 2 +- inherit_graph_58.svg | 10 +- inherit_graph_59.map | 2 +- inherit_graph_59.md5 | 2 +- inherit_graph_59.svg | 10 +- inherit_graph_60.map | 2 +- inherit_graph_60.md5 | 2 +- inherit_graph_60.svg | 10 +- inherit_graph_61.map | 2 +- inherit_graph_61.md5 | 2 +- inherit_graph_61.svg | 10 +- inherit_graph_62.map | 2 +- inherit_graph_62.md5 | 2 +- inherit_graph_62.svg | 10 +- inherit_graph_63.map | 2 +- inherit_graph_63.md5 | 2 +- inherit_graph_63.svg | 8 +- inherit_graph_64.map | 2 +- inherit_graph_64.md5 | 2 +- inherit_graph_64.svg | 14 +- inherit_graph_65.map | 2 +- inherit_graph_65.md5 | 2 +- inherit_graph_65.svg | 15 +- inherit_graph_66.map | 2 +- inherit_graph_66.md5 | 2 +- inherit_graph_66.svg | 10 +- inherit_graph_67.map | 2 +- inherit_graph_67.md5 | 2 +- inherit_graph_67.svg | 10 +- inherit_graph_68.map | 2 +- inherit_graph_68.md5 | 2 +- inherit_graph_68.svg | 10 +- inherit_graph_69.map | 2 +- inherit_graph_69.md5 | 2 +- inherit_graph_69.svg | 4 +- inherit_graph_70.map | 2 +- inherit_graph_70.md5 | 2 +- inherit_graph_70.svg | 12 +- inherit_graph_71.map | 2 +- inherit_graph_71.md5 | 2 +- inherit_graph_71.svg | 10 +- inherit_graph_72.map | 2 +- inherit_graph_72.md5 | 2 +- inherit_graph_72.svg | 12 +- inherit_graph_73.map | 2 +- inherit_graph_73.md5 | 2 +- inherit_graph_73.svg | 12 +- inherit_graph_74.map | 2 +- inherit_graph_74.md5 | 2 +- inherit_graph_74.svg | 12 +- inherit_graph_75.map | 2 +- inherit_graph_75.md5 | 2 +- inherit_graph_75.svg | 4 +- inherit_graph_76.map | 2 +- inherit_graph_76.md5 | 2 +- inherit_graph_76.svg | 13 +- inherit_graph_77.map | 2 +- inherit_graph_77.md5 | 2 +- inherit_graph_77.svg | 13 +- inherit_graph_78.map | 2 +- inherit_graph_78.md5 | 2 +- inherit_graph_78.svg | 12 +- inherit_graph_79.map | 2 +- inherit_graph_79.md5 | 2 +- inherit_graph_79.svg | 12 +- inherit_graph_80.map | 2 +- inherit_graph_80.md5 | 2 +- inherit_graph_80.svg | 13 +- inherit_graph_81.map | 2 +- inherit_graph_81.md5 | 2 +- inherit_graph_81.svg | 10 +- inherit_graph_82.map | 2 +- inherit_graph_82.md5 | 2 +- inherit_graph_82.svg | 10 +- inherit_graph_83.map | 4 +- inherit_graph_83.md5 | 2 +- inherit_graph_83.svg | 48 +- inherit_graph_84.map | 4 +- inherit_graph_84.md5 | 2 +- inherit_graph_84.svg | 48 +- inherit_graph_85.map | 2 +- inherit_graph_85.md5 | 2 +- inherit_graph_85.svg | 13 +- inherit_graph_86.map | 2 +- inherit_graph_86.md5 | 2 +- inherit_graph_86.svg | 13 +- inherit_graph_87.map | 2 +- inherit_graph_87.md5 | 2 +- inherit_graph_87.svg | 13 +- inherit_graph_88.map | 2 +- inherit_graph_88.md5 | 2 +- inherit_graph_88.svg | 13 +- inherit_graph_89.map | 2 +- inherit_graph_89.md5 | 2 +- inherit_graph_89.svg | 10 +- inherit_graph_90.map | 2 +- inherit_graph_90.md5 | 2 +- inherit_graph_90.svg | 10 +- inherit_graph_91.map | 2 +- inherit_graph_91.md5 | 2 +- inherit_graph_91.svg | 10 +- inherit_graph_92.map | 2 +- inherit_graph_92.md5 | 2 +- inherit_graph_92.svg | 10 +- inherit_graph_93.map | 2 +- inherit_graph_93.md5 | 2 +- inherit_graph_93.svg | 4 +- inherit_graph_94.map | 8 +- inherit_graph_94.md5 | 2 +- inherit_graph_94.svg | 104 +--- inherit_graph_95.map | 8 +- inherit_graph_95.md5 | 2 +- inherit_graph_95.svg | 104 +++- inherit_graph_96.map | 2 +- inherit_graph_96.md5 | 2 +- inherit_graph_96.svg | 10 +- inherit_graph_97.map | 2 +- inherit_graph_97.md5 | 2 +- inherit_graph_97.svg | 10 +- inherit_graph_98.map | 2 +- inherit_graph_98.md5 | 2 +- inherit_graph_98.svg | 10 +- inherit_graph_99.map | 2 +- inherit_graph_99.md5 | 2 +- inherit_graph_99.svg | 10 +- inherits.html | 88 +-- namespaces.html | 207 ++++---- namespaces_dup.js | 1 + navtreedata.js | 18 +- navtreeindex0.js | 496 ++++++++--------- navtreeindex1.js | 500 +++++++++--------- navtreeindex10.js | 78 +-- navtreeindex11.js | 122 ++--- navtreeindex12.js | 66 +-- navtreeindex13.js | 19 +- navtreeindex2.js | 102 ++-- navtreeindex3.js | 60 +-- navtreeindex4.js | 34 +- navtreeindex5.js | 142 ++--- navtreeindex6.js | 92 ++-- navtreeindex7.js | 184 +++---- navtreeindex8.js | 80 +-- navtreeindex9.js | 88 +-- search/all_10.js | 30 +- search/all_11.js | 18 +- search/all_14.js | 4 +- search/all_15.js | 10 +- search/all_16.js | 4 +- search/all_17.js | 63 +-- search/all_19.js | 11 +- search/all_1a.js | 9 +- search/all_1c.js | 127 ++--- search/all_2.js | 4 +- search/all_3.js | 61 ++- search/all_4.js | 165 +++--- search/all_6.js | 57 +- search/all_7.js | 4 +- search/all_8.js | 4 +- search/all_a.js | 420 +++++++-------- search/all_c.js | 45 +- search/all_d.js | 61 +-- search/all_e.js | 6 +- search/all_f.js | 4 +- search/classes_15.js | 15 +- search/classes_2.js | 4 +- search/classes_a.js | 3 +- search/classes_d.js | 4 +- search/files_b.js | 15 +- search/functions_10.js | 12 +- search/functions_13.js | 4 +- search/functions_14.js | 51 +- search/functions_15.js | 4 +- search/functions_1b.js | 127 ++--- search/functions_2.js | 4 +- search/functions_3.js | 89 ++-- search/functions_5.js | 41 +- search/functions_6.js | 143 ++--- search/functions_7.js | 4 +- search/functions_9.js | 200 +++---- search/functions_b.js | 9 +- search/functions_d.js | 2 +- search/functions_f.js | 12 +- search/namespaces_9.js | 9 +- search/variables_16.js | 3 +- search/variables_17.js | 3 +- 258 files changed, 4559 insertions(+), 2699 deletions(-) create mode 100644 d1/dbb/k__nearest__neighbors_8cpp__incl.map create mode 100644 d1/dbb/k__nearest__neighbors_8cpp__incl.md5 create mode 100644 d1/dbb/k__nearest__neighbors_8cpp__incl.svg create mode 100644 d4/d3e/k__nearest__neighbors_8cpp.html create mode 100644 d4/d3e/k__nearest__neighbors_8cpp.js create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.map create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.md5 create mode 100644 d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.svg create mode 100644 d7/d4c/namespacek__nearest__neighbors.html create mode 100644 d7/dc7/classmachine__learning_1_1k__nearest__neighbors_1_1_knn-members.html create mode 100644 da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn.html create mode 100644 da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn.js create mode 100644 da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn_a62e152db014cd4de675fa906e5ef2861_cgraph.map create mode 100644 da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn_a62e152db014cd4de675fa906e5ef2861_cgraph.md5 create mode 100644 da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn_a62e152db014cd4de675fa906e5ef2861_cgraph.svg create mode 100644 dd/d58/classmachine__learning_1_1k__nearest__neighbors_1_1_knn__coll__graph.map create mode 100644 dd/d58/classmachine__learning_1_1k__nearest__neighbors_1_1_knn__coll__graph.md5 create mode 100644 dd/d58/classmachine__learning_1_1k__nearest__neighbors_1_1_knn__coll__graph.svg create mode 100644 inherit_graph_101.map create mode 100644 inherit_graph_101.md5 create mode 100644 inherit_graph_101.svg diff --git a/annotated.html b/annotated.html index 2582ee831..2061e3ca1 100644 --- a/annotated.html +++ b/annotated.html @@ -156,11 +156,13 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable();  Ccomparison_operatorCustom comparator for open_list  CInfoStruct that handles all the information related to the current state  CEightPuzzleA class defining EightPuzzle/15-Puzzle game - Nneural_network - Nlayers - CDenseLayer - CNeuralNetwork - Cadaline + Nk_nearest_neighbors + CKnnK-Nearest Neighbors (Knn) class using Euclidean distance as distance metric + Nneural_network + Nlayers + CDenseLayer + CNeuralNetwork + Cadaline  NmathFor IO operations  Nncr_modulo_p  CNCRModuloPClass which contains all methods required for calculating nCr mod p @@ -218,8 +220,8 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable();  Cbst_nodeA struct to represent a node in the Binary Search Tree  CBtree  Ccll - CCompareComparator class for priority queue - Ccompare + Ccompare + CCompareComparator class for priority queue  CComplexClass Complex to represent complex numbers as a field  CCycleCheck  Cdouble_linked_list @@ -238,8 +240,8 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable();  CMinHeap  CMinHeapNode  Cmst - CNode - Cnode + Cnode + CNode  CPoint  Cquery  CQueue diff --git a/annotated_dup.js b/annotated_dup.js index fc55e206e..d5814c5b6 100644 --- a/annotated_dup.js +++ b/annotated_dup.js @@ -71,6 +71,9 @@ var annotated_dup = [ "AyStarSearch", "da/d02/classmachine__learning_1_1aystar__search_1_1_ay_star_search.html", "da/d02/classmachine__learning_1_1aystar__search_1_1_ay_star_search" ], [ "EightPuzzle", "dd/d9c/classmachine__learning_1_1aystar__search_1_1_eight_puzzle.html", "dd/d9c/classmachine__learning_1_1aystar__search_1_1_eight_puzzle" ] ] ], + [ "k_nearest_neighbors", null, [ + [ "Knn", "da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn.html", "da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn" ] + ] ], [ "neural_network", null, [ [ "layers", null, [ [ "DenseLayer", "dc/d93/classmachine__learning_1_1neural__network_1_1layers_1_1_dense_layer.html", "dc/d93/classmachine__learning_1_1neural__network_1_1layers_1_1_dense_layer" ] @@ -156,8 +159,8 @@ var annotated_dup = [ "binary_search_tree", "d9/dde/classbinary__search__tree.html", "d9/dde/classbinary__search__tree" ], [ "Btree", "d9/d90/struct_btree.html", null ], [ "cll", "d5/d15/classcll.html", null ], - [ "Compare", "de/d4a/class_compare.html", "de/d4a/class_compare" ], [ "compare", "d1/db3/structcompare.html", null ], + [ "Compare", "de/d4a/class_compare.html", "de/d4a/class_compare" ], [ "Complex", "da/d5a/class_complex.html", "da/d5a/class_complex" ], [ "CycleCheck", "d3/dbb/class_cycle_check.html", "d3/dbb/class_cycle_check" ], [ "double_linked_list", "d9/dee/classdouble__linked__list.html", null ], @@ -176,8 +179,8 @@ var annotated_dup = [ "MinHeap", "d2/d05/class_min_heap.html", "d2/d05/class_min_heap" ], [ "MinHeapNode", "d5/d29/struct_min_heap_node.html", null ], [ "mst", "d1/d77/structmst.html", null ], - [ "Node", "db/d8b/struct_node.html", null ], [ "node", "d5/da1/structnode.html", null ], + [ "Node", "db/d8b/struct_node.html", null ], [ "Point", "d8/dc8/struct_point.html", "d8/dc8/struct_point" ], [ "query", "dd/d1b/structquery.html", null ], [ "Queue", "dc/db5/struct_queue.html", null ], diff --git a/classes.html b/classes.html index caf42570a..82deb692a 100644 --- a/classes.html +++ b/classes.html @@ -100,7 +100,7 @@ $(document).ready(function(){initNavTree('classes.html',''); initResizable(); })
Class Index
-
A | B | C | D | E | F | G | H | I | L | M | N | P | Q | R | S | T | U | W
+
A | B | C | D | E | F | G | H | I | K | L | M | N | P | Q | R | S | T | U | W
A
@@ -110,7 +110,7 @@ $(document).ready(function(){initNavTree('classes.html',''); initResizable(); })
binary_search_tree
BinaryTree (operations_on_datastructures::reverse_binary_tree)
BinaryTree (others::iterative_tree_traversals)
Bitset (data_structures)
BloomFilter (data_structures)
binary_search_tree::bst_node
BT (others::recursive_tree_traversals)
Btree
C
-
CircularLinkedList (operations_on_datastructures::circular_linked_list)
cll
Compare
compare
AyStarSearch::comparison_operator (machine_learning::aystar_search)
Complex
Convexhull (geometry::jarvis)
CycleCheck
+
CircularLinkedList (operations_on_datastructures::circular_linked_list)
cll
compare
Compare
AyStarSearch::comparison_operator (machine_learning::aystar_search)
Complex
Convexhull (geometry::jarvis)
CycleCheck
D
DenseLayer (machine_learning::neural_network::layers)
double_linked_list
dsu
@@ -130,33 +130,36 @@ $(document).ready(function(){initNavTree('classes.html',''); initResizable(); })
I
AyStarSearch::Info (machine_learning::aystar_search)
is_arithmetic< uint128_t > (std)
is_arithmetic< uint256_t > (std)
is_integral< uint128_t > (std)
is_integral< uint256_t > (std)
is_unsigned< uint128_t > (std)
is_unsigned< uint256_t > (std)
Item
+
K
+
Knn (machine_learning::k_nearest_neighbors)
+
L
large_number
link (data_structures::linked_list)
linkedlist
list (data_structures::linked_list)
list (data_structures::list_array)
list
ListNode
LowestCommonAncestor (graph)
LRUCache (others::lru_cache)
-
+
M
Matrix (divide_and_conquer::strassens_multiplication)
MinHeap
MinHeapNode
mst
-
-
N
-
NCRModuloP (math::ncr_modulo_p)
NeuralNetwork (machine_learning::neural_network)
Node (data_structures::linked_list)
Node (data_structures)
Node (data_structures::tree_234)
Trie::Node (data_structures::trie_using_hashmap)
Node
node
Node (operations_on_datastructures::circular_linked_list)
Node (operations_on_datastructures::inorder_traversal_of_bst)
Node (operations_on_datastructures::reverse_binary_tree)
Node (others::iterative_tree_traversals)
Node (others::recursive_tree_traversals)
perSegTree::Node (range_queries)
Node (search::sublist_search)
+
N
+
NCRModuloP (math::ncr_modulo_p)
NeuralNetwork (machine_learning::neural_network)
Node (data_structures::linked_list)
Node (data_structures)
Node (data_structures::tree_234)
Trie::Node (data_structures::trie_using_hashmap)
node
Node
Node (operations_on_datastructures::circular_linked_list)
Node (operations_on_datastructures::inorder_traversal_of_bst)
Node (operations_on_datastructures::reverse_binary_tree)
Node (others::iterative_tree_traversals)
Node (others::recursive_tree_traversals)
perSegTree::Node (range_queries)
Node (search::sublist_search)
+
P
perSegTree (range_queries)
Point (ciphers::elliptic_curve_key_exchange)
Point (geometry::grahamscan)
Point (geometry::jarvis)
Point (math)
Point
-
+
Q
query
Queue
queue
Queue_Array (data_structures::queue_using_array)
-
+
R
RBtree
RootedTree (graph)
-
+
S
SegmentIntersection
SG (range_queries::heavy_light_decomposition)
SkipList (data_structures)
Solution
Sparse_table (data_structures::sparse_table)
Stack (data_structures::stack_using_queue)
Stack (others::postfix_expression)
stack
stack_linkedList
stats_computer1 (statistics)
stats_computer2 (statistics)
-
+
T
TestCases
Tnode (operations_on_datastructures::trie_operations)
tower
Tree (range_queries::heavy_light_decomposition)
Tree234 (data_structures::tree_234)
trie (data_structures)
Trie (data_structures::trie_using_hashmap)
Trie
Trie::TrieNode
-
+
U
uint128_t
uint256_t
-
+
W
WindowedMedian (probability::windowed_median)
diff --git a/d1/dbb/k__nearest__neighbors_8cpp__incl.map b/d1/dbb/k__nearest__neighbors_8cpp__incl.map new file mode 100644 index 000000000..5d4620449 --- /dev/null +++ b/d1/dbb/k__nearest__neighbors_8cpp__incl.map @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/d1/dbb/k__nearest__neighbors_8cpp__incl.md5 b/d1/dbb/k__nearest__neighbors_8cpp__incl.md5 new file mode 100644 index 000000000..915b51dc7 --- /dev/null +++ b/d1/dbb/k__nearest__neighbors_8cpp__incl.md5 @@ -0,0 +1 @@ +1a4de3c821cf159b7bea4b90b5fbb1bd \ No newline at end of file diff --git a/d1/dbb/k__nearest__neighbors_8cpp__incl.svg b/d1/dbb/k__nearest__neighbors_8cpp__incl.svg new file mode 100644 index 000000000..5401a6d18 --- /dev/null +++ b/d1/dbb/k__nearest__neighbors_8cpp__incl.svg @@ -0,0 +1,127 @@ + + + + + + +machine_learning/k_nearest_neighbors.cpp + + +Node1 + + +machine_learning/k +_nearest_neighbors.cpp + + + + + +Node2 + + +algorithm + + + + + +Node1->Node2 + + + + + +Node3 + + +cassert + + + + + +Node1->Node3 + + + + + +Node4 + + +cmath + + + + + +Node1->Node4 + + + + + +Node5 + + +iostream + + + + + +Node1->Node5 + + + + + +Node6 + + +numeric + + + + + +Node1->Node6 + + + + + +Node7 + + +unordered_map + + + + + +Node1->Node7 + + + + + +Node8 + + +vector + + + + + +Node1->Node8 + + + + + diff --git a/d4/d3e/k__nearest__neighbors_8cpp.html b/d4/d3e/k__nearest__neighbors_8cpp.html new file mode 100644 index 000000000..08c652201 --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp.html @@ -0,0 +1,366 @@ + + + + + + + +Algorithms_in_C++: machine_learning/k_nearest_neighbors.cpp File Reference + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
k_nearest_neighbors.cpp File Reference
+
+
+ +

Implementation of [K-Nearest Neighbors algorithm] (https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm). +More...

+
#include <algorithm>
+#include <cassert>
+#include <cmath>
+#include <iostream>
+#include <numeric>
+#include <unordered_map>
+#include <vector>
+
+Include dependency graph for k_nearest_neighbors.cpp:
+
+
+
+
+
+ + + + +

+Classes

class  machine_learning::k_nearest_neighbors::Knn
 K-Nearest Neighbors (Knn) class using Euclidean distance as distance metric. More...
 
+ + + + + + + +

+Namespaces

namespace  machine_learning
 A* search algorithm
 
namespace  k_nearest_neighbors
 Functions for the [K-Nearest Neighbors algorithm] (https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm) implementation.
 
+ + + + + + + + + + + +

+Functions

template<typename T >
double machine_learning::k_nearest_neighbors::euclidean_distance (const std::vector< T > &a, const std::vector< T > &b)
 Compute the Euclidean distance between two vectors.
 
static void test ()
 Self-test implementations.
 
int main (int argc, char *argv[])
 Main function.
 
+

Detailed Description

+

Implementation of [K-Nearest Neighbors algorithm] (https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm).

+
Author
Luiz Carlos Cosmi Filho
+

K-nearest neighbors algorithm, also known as KNN or k-NN, is a supervised learning classifier, which uses proximity to make classifications. This implementantion uses the Euclidean Distance as distance metric to find the K-nearest neighbors.

+

Function Documentation

+ +

◆ euclidean_distance()

+ +
+
+
+template<typename T >
+ + + + + + + + + + + + + + + + + + +
double machine_learning::k_nearest_neighbors::euclidean_distance (const std::vector< T > & a,
const std::vector< T > & b 
)
+
+ +

Compute the Euclidean distance between two vectors.

+
Template Parameters
+ + +
Ttypename of the vector
+
+
+
Parameters
+ + + +
afirst unidimentional vector
bsecond unidimentional vector
+
+
+
Returns
double scalar representing the Euclidean distance between provided vectors
+
43 {
+ +
45 std::transform(a.begin(), a.end(), b.begin(), std::back_inserter(aux),
+
46 [](T x1, T x2) { return std::pow((x1 - x2), 2); });
+
47 aux.shrink_to_fit();
+
48 return std::sqrt(std::accumulate(aux.begin(), aux.end(), 0.0));
+
49}
+
T accumulate(T... args)
+
T back_inserter(T... args)
+
T begin(T... args)
+
T end(T... args)
+
T shrink_to_fit(T... args)
+
T sqrt(T... args)
+
T transform(T... args)
+ +
+Here is the call graph for this function:
+
+
+
+
+ +
+
+ +

◆ main()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int main (int argc,
char * argv[] 
)
+
+ +

Main function.

+
Parameters
+ + + +
argccommandline argument count (ignored)
argvcommandline array of arguments (ignored)
+
+
+
Returns
int 0 on exit
+
193 {
+
194 test(); // run self-test implementations
+
195 return 0;
+
196}
+
static void test()
Self-test implementations.
Definition: k_nearest_neighbors.cpp:140
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+ +

◆ test()

+ +
+
+ + + + + +
+ + + + + + + +
static void test ()
+
+static
+
+ +

Self-test implementations.

+
Returns
void
+
140 {
+
141 std::cout << "------- Test 1 -------" << std::endl;
+
142 std::vector<std::vector<double>> X1 = {{0.0, 0.0}, {0.25, 0.25},
+
143 {0.0, 0.5}, {0.5, 0.5},
+
144 {1.0, 0.5}, {1.0, 1.0}};
+
145 std::vector<int> Y1 = {1, 1, 1, 1, 2, 2};
+
146 auto model1 = machine_learning::k_nearest_neighbors::Knn(X1, Y1);
+
147 std::vector<double> sample1 = {1.2, 1.2};
+
148 std::vector<double> sample2 = {0.1, 0.1};
+
149 std::vector<double> sample3 = {0.1, 0.5};
+
150 std::vector<double> sample4 = {1.0, 0.75};
+
151 assert(model1.predict(sample1, 2) == 2);
+
152 assert(model1.predict(sample2, 2) == 1);
+
153 assert(model1.predict(sample3, 2) == 1);
+
154 assert(model1.predict(sample4, 2) == 2);
+
155 std::cout << "... Passed" << std::endl;
+
156 std::cout << "------- Test 2 -------" << std::endl;
+ +
158 {0.0, 0.0, 0.0}, {0.25, 0.25, 0.0}, {0.0, 0.5, 0.0}, {0.5, 0.5, 0.0},
+
159 {1.0, 0.5, 0.0}, {1.0, 1.0, 0.0}, {1.0, 1.0, 1.0}, {1.5, 1.5, 1.0}};
+
160 std::vector<int> Y2 = {1, 1, 1, 1, 2, 2, 3, 3};
+
161 auto model2 = machine_learning::k_nearest_neighbors::Knn(X2, Y2);
+
162 std::vector<double> sample5 = {1.2, 1.2, 0.0};
+
163 std::vector<double> sample6 = {0.1, 0.1, 0.0};
+
164 std::vector<double> sample7 = {0.1, 0.5, 0.0};
+
165 std::vector<double> sample8 = {1.0, 0.75, 1.0};
+
166 assert(model2.predict(sample5, 2) == 2);
+
167 assert(model2.predict(sample6, 2) == 1);
+
168 assert(model2.predict(sample7, 2) == 1);
+
169 assert(model2.predict(sample8, 2) == 3);
+
170 std::cout << "... Passed" << std::endl;
+
171 std::cout << "------- Test 3 -------" << std::endl;
+
172 std::vector<std::vector<double>> X3 = {{0.0}, {1.0}, {2.0}, {3.0},
+
173 {4.0}, {5.0}, {6.0}, {7.0}};
+
174 std::vector<int> Y3 = {1, 1, 1, 1, 2, 2, 2, 2};
+
175 auto model3 = machine_learning::k_nearest_neighbors::Knn(X3, Y3);
+
176 std::vector<double> sample9 = {0.5};
+
177 std::vector<double> sample10 = {2.9};
+
178 std::vector<double> sample11 = {5.5};
+
179 std::vector<double> sample12 = {7.5};
+
180 assert(model3.predict(sample9, 3) == 1);
+
181 assert(model3.predict(sample10, 3) == 1);
+
182 assert(model3.predict(sample11, 3) == 2);
+
183 assert(model3.predict(sample12, 3) == 2);
+
184 std::cout << "... Passed" << std::endl;
+
185}
+ +
K-Nearest Neighbors (Knn) class using Euclidean distance as distance metric.
Definition: k_nearest_neighbors.cpp:55
+
T endl(T... args)
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+
+
+ + + + diff --git a/d4/d3e/k__nearest__neighbors_8cpp.js b/d4/d3e/k__nearest__neighbors_8cpp.js new file mode 100644 index 000000000..e78f50eed --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp.js @@ -0,0 +1,7 @@ +var k__nearest__neighbors_8cpp = +[ + [ "machine_learning::k_nearest_neighbors::Knn", "da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn.html", "da/d94/classmachine__learning_1_1k__nearest__neighbors_1_1_knn" ], + [ "euclidean_distance", "d4/d3e/k__nearest__neighbors_8cpp.html#ad6ae16e50bb153ebaa7251d0aaa97b69", null ], + [ "main", "d4/d3e/k__nearest__neighbors_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97", null ], + [ "test", "d4/d3e/k__nearest__neighbors_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ] +]; \ No newline at end of file diff --git a/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map b/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map new file mode 100644 index 000000000..0c3b40fae --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 b/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 new file mode 100644 index 000000000..3bac83066 --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 @@ -0,0 +1 @@ +08ab1cf65a70138379f6873c9be26b36 \ No newline at end of file diff --git a/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg b/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg new file mode 100644 index 000000000..d1b2ab0d9 --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg @@ -0,0 +1,51 @@ + + + + + + +main + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + +Node3 + + +std::endl + + + + + +Node2->Node3 + + + + + diff --git a/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map new file mode 100644 index 000000000..e1af595fe --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -0,0 +1,4 @@ + + + + diff --git a/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 new file mode 100644 index 000000000..77de60e3f --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -0,0 +1 @@ +f486c9c49ba8056684cc8746d21a532f \ No newline at end of file diff --git a/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg new file mode 100644 index 000000000..c259cfca8 --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -0,0 +1,36 @@ + + + + + + +test + + +Node1 + + +test + + + + + +Node2 + + +std::endl + + + + + +Node1->Node2 + + + + + diff --git a/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.map b/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.map new file mode 100644 index 000000000..12bcc2576 --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.map @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.md5 b/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.md5 new file mode 100644 index 000000000..b34b4139a --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.md5 @@ -0,0 +1 @@ +25cffb0c097dbabf156c105194fda8d9 \ No newline at end of file diff --git a/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.svg b/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.svg new file mode 100644 index 000000000..64663fb4a --- /dev/null +++ b/d4/d3e/k__nearest__neighbors_8cpp_ad6ae16e50bb153ebaa7251d0aaa97b69_cgraph.svg @@ -0,0 +1,135 @@ + + + + + + +machine_learning::k_nearest_neighbors::euclidean_distance + + +Node1 + + +machine_learning::k +_nearest_neighbors:: +euclidean_distance + + + + + +Node1->Node1 + + + + + +Node2 + + +std::accumulate + + + + + +Node1->Node2 + + + + + +Node3 + + +std::back_inserter + + + + + +Node1->Node3 + + + + + +Node4 + + +std::vector::begin + + + + + +Node1->Node4 + + + + + +Node5 + + +std::vector::end + + + + + +Node1->Node5 + + + + + +Node6 + + +std::vector::shrink +_to_fit + + + + + +Node1->Node6 + + + + + +Node7 + + +std::sqrt + + + + + +Node1->Node7 + + + + + +Node8 + + +std::transform + + + + + +Node1->Node8 + + + + + diff --git a/d5/d88/md__d_i_r_e_c_t_o_r_y.html b/d5/d88/md__d_i_r_e_c_t_o_r_y.html index 56ad24a90..ad3e5ce08 100644 --- a/d5/d88/md__d_i_r_e_c_t_o_r_y.html +++ b/d5/d88/md__d_i_r_e_c_t_o_r_y.html @@ -295,6 +295,7 @@ Machine Learning
diff --git a/functions_func_o.html b/functions_func_o.html index a9d6d7ab0..445b653a9 100644 --- a/functions_func_o.html +++ b/functions_func_o.html @@ -126,9 +126,9 @@ $(document).ready(function(){initNavTree('functions_func_o.html',''); initResiza
  • operator<() : machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • operator<<() : uint128_t, uint256_t
  • operator<<=() : uint128_t, uint256_t
  • -
  • operator<=() : machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • -
  • operator=() : Complex, large_number, machine_learning::aystar_search::AyStarSearch< Puzzle >::Info, machine_learning::aystar_search::EightPuzzle< N >, machine_learning::neural_network::layers::DenseLayer, machine_learning::neural_network::NeuralNetwork, operations_on_datastructures::circular_linked_list::CircularLinkedList, uint128_t, uint256_t
  • -
  • operator==() : ciphers::elliptic_curve_key_exchange::Point, divide_and_conquer::strassens_multiplication::Matrix< T, typename >, machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • +
  • operator<=() : machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • +
  • operator=() : Complex, large_number, machine_learning::aystar_search::AyStarSearch< Puzzle >::Info, machine_learning::aystar_search::EightPuzzle< N >, machine_learning::k_nearest_neighbors::Knn, machine_learning::neural_network::layers::DenseLayer, machine_learning::neural_network::NeuralNetwork, operations_on_datastructures::circular_linked_list::CircularLinkedList, uint128_t, uint256_t
  • +
  • operator==() : ciphers::elliptic_curve_key_exchange::Point, divide_and_conquer::strassens_multiplication::Matrix< T, typename >, machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • operator>() : uint128_t, uint256_t
  • operator>=() : uint128_t, uint256_t
  • operator>>() : uint128_t, uint256_t
  • diff --git a/functions_func_p.html b/functions_func_p.html index 00571aeb3..0316f4fde 100644 --- a/functions_func_p.html +++ b/functions_func_p.html @@ -106,7 +106,7 @@ $(document).ready(function(){initNavTree('functions_func_p.html',''); initResiza
  • populate_up() : graph::LowestCommonAncestor
  • postorder() : others::recursive_tree_traversals::BT
  • postOrderIterative() : others::iterative_tree_traversals::BinaryTree
  • -
  • predict() : machine_learning::adaline
  • +
  • predict() : machine_learning::adaline, machine_learning::k_nearest_neighbors::Knn
  • predict_words() : data_structures::trie_using_hashmap::Trie
  • preorder() : others::recursive_tree_traversals::BT
  • preOrderIterative() : others::iterative_tree_traversals::BinaryTree
  • diff --git a/functions_func_u.html b/functions_func_u.html index d8191ebfb..7e9d08f65 100644 --- a/functions_func_u.html +++ b/functions_func_u.html @@ -102,8 +102,8 @@ $(document).ready(function(){initNavTree('functions_func_u.html',''); initResiza

    - u -

    diff --git a/functions_func_~.html b/functions_func_~.html index 0bb1d00bf..e40c34737 100644 --- a/functions_func_~.html +++ b/functions_func_~.html @@ -104,6 +104,7 @@ $(document).ready(function(){initNavTree('functions_func_~.html',''); initResiza
  • ~DenseLayer() : machine_learning::neural_network::layers::DenseLayer
  • ~EightPuzzle() : machine_learning::aystar_search::EightPuzzle< N >
  • ~Info() : machine_learning::aystar_search::AyStarSearch< Puzzle >::Info
  • +
  • ~Knn() : machine_learning::k_nearest_neighbors::Knn
  • ~NeuralNetwork() : machine_learning::neural_network::NeuralNetwork
  • ~uint128_t() : uint128_t
  • ~uint256_t() : uint256_t
  • diff --git a/functions_k.html b/functions_k.html index 445157f5d..3faff3042 100644 --- a/functions_k.html +++ b/functions_k.html @@ -101,6 +101,7 @@ $(document).ready(function(){initNavTree('functions_k.html',''); initResizable()

    - k -

    diff --git a/functions_o.html b/functions_o.html index 984eb06be..0d3294edb 100644 --- a/functions_o.html +++ b/functions_o.html @@ -127,8 +127,8 @@ $(document).ready(function(){initNavTree('functions_o.html',''); initResizable()
  • operator<< : ciphers::elliptic_curve_key_exchange::Point, large_number, machine_learning::adaline, machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • operator<<=() : uint128_t, uint256_t
  • operator<=() : machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • -
  • operator=() : Complex, large_number, machine_learning::aystar_search::AyStarSearch< Puzzle >::Info, machine_learning::aystar_search::EightPuzzle< N >, machine_learning::neural_network::layers::DenseLayer, machine_learning::neural_network::NeuralNetwork, operations_on_datastructures::circular_linked_list::CircularLinkedList, uint128_t, uint256_t
  • -
  • operator==() : ciphers::elliptic_curve_key_exchange::Point, divide_and_conquer::strassens_multiplication::Matrix< T, typename >, large_number, machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • +
  • operator=() : Complex, large_number, machine_learning::aystar_search::AyStarSearch< Puzzle >::Info, machine_learning::aystar_search::EightPuzzle< N >, machine_learning::k_nearest_neighbors::Knn, machine_learning::neural_network::layers::DenseLayer, machine_learning::neural_network::NeuralNetwork, operations_on_datastructures::circular_linked_list::CircularLinkedList, uint128_t, uint256_t
  • +
  • operator==() : ciphers::elliptic_curve_key_exchange::Point, divide_and_conquer::strassens_multiplication::Matrix< T, typename >, large_number, machine_learning::aystar_search::EightPuzzle< N >, uint128_t, uint256_t
  • operator>() : uint128_t, uint256_t
  • operator>=() : uint128_t, uint256_t
  • operator>> : statistics::stats_computer1< T >, statistics::stats_computer2< T >, uint128_t, uint256_t
  • diff --git a/functions_p.html b/functions_p.html index 3d0a04fc7..04d5b8704 100644 --- a/functions_p.html +++ b/functions_p.html @@ -113,7 +113,7 @@ $(document).ready(function(){initNavTree('functions_p.html',''); initResizable()
  • populate_up() : graph::LowestCommonAncestor
  • postorder() : others::recursive_tree_traversals::BT
  • postOrderIterative() : others::iterative_tree_traversals::BinaryTree
  • -
  • predict() : machine_learning::adaline
  • +
  • predict() : machine_learning::adaline, machine_learning::k_nearest_neighbors::Knn
  • predict_words() : data_structures::trie_using_hashmap::Trie
  • preorder() : others::recursive_tree_traversals::BT
  • preOrderIterative() : others::iterative_tree_traversals::BinaryTree
  • diff --git a/functions_u.html b/functions_u.html index aabdd785a..8f8113d6a 100644 --- a/functions_u.html +++ b/functions_u.html @@ -102,8 +102,8 @@ $(document).ready(function(){initNavTree('functions_u.html',''); initResizable()

    - u -