{"id":85,"date":"2017-05-24T18:58:34","date_gmt":"2017-05-24T18:58:34","guid":{"rendered":"http:\/\/bskog.com\/ai\/?p=85"},"modified":"2017-05-24T18:58:34","modified_gmt":"2017-05-24T18:58:34","slug":"k-nearest-neighbors","status":"publish","type":"post","link":"http:\/\/bskog.com\/ai\/2017\/05\/24\/k-nearest-neighbors\/","title":{"rendered":"k-Nearest Neighbors"},"content":{"rendered":"<p>One of the simples algorithms in Machine Learning is k-Neares Neighbors. It is considered a &#8220;lazy learning&#8221; algorithm where all the calculations are deferred until classification.<br \/>\nIt works like this:<br \/>\nYou have out training data with its features and labels. Then upon classification, or testing the data, you take the k-nearest neighbors and assign the label for your test feature with what the majority vote of the k-nearest neighbors is. If k=1 then your features label with be that of its closes neighbor.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/c\/cc\/Data3classes.png\/364px-Data3classes.png\" class=\"alignnone size-full\" \/>The Dataset <\/p>\n<p><img \/>The 1NN classification map<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Map5NN.png\/365px-Map5NN.png\" width=\"365\" height=\"240\" class=\"alignnone size-full\" \/>The 5NN classification map<\/p>\n<p>(Images from: <a href=\"https:\/\/en.wikipedia.org\/wiki\/K-nearest_neighbors_algorithm\">wikipedia<\/a>)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the simples algorithms in Machine Learning is k-Neares Neighbors. It is considered a &#8220;lazy learning&#8221; algorithm where all the calculations are deferred until classification. It works like this: You have out training data with its features and labels. Then upon classification, or testing the data, you take the k-nearest neighbors and assign the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/bskog.com\/ai\/2017\/05\/24\/k-nearest-neighbors\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;k-Nearest Neighbors&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,32,34],"tags":[],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-algorithms","category-shallow-machine-learning","category-supervised-machine-learning"],"_links":{"self":[{"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":0,"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"wp:attachment":[{"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bskog.com\/ai\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}