{"id":1848,"date":"2020-09-20T19:31:39","date_gmt":"2020-09-20T19:31:39","guid":{"rendered":"http:\/\/optimumsportsperformance.com\/blog\/?p=1848"},"modified":"2020-09-21T13:05:01","modified_gmt":"2020-09-21T13:05:01","slug":"tidyx-28-shiny-apps-part-3-k-nearest-neighbor-and-reactivity","status":"publish","type":"post","link":"https:\/\/optimumsportsperformance.com\/blog\/tidyx-28-shiny-apps-part-3-k-nearest-neighbor-and-reactivity\/","title":{"rendered":"TidyX 28: Shiny Apps Part 3 &#8211; K-Nearest Neighbor and Reactivity"},"content":{"rendered":"<p>In installment three of our {<strong><span style=\"color: #0000ff;\">shiny<\/span><\/strong>} dashboard from scratch series, <a href=\"https:\/\/twitter.com\/ellis_hughes\"><strong><span style=\"color: #0000ff;\">Ellis Hughes<\/span><\/strong><\/a> and discuss how to use the K-Nearest Neighbor algorithm to forecast a player&#8217;s career projection for the Value Over Replacement Player (VORP) metric.<\/p>\n<p>We then take this analysis and build upon our {<span style=\"color: #0000ff;\"><strong>shiny<\/strong><\/span>} app from the previous two weeks by walking through how to add statistical analysis to the server. This will allow you to add your analytics models to your {<span style=\"color: #0000ff;\"><strong>shiny<\/strong><\/span>} app so that the model runs under the hood while the user sees the output. We also go over reactivity and add an action button to give the user more control of the output they see.<\/p>\n<p>The finished result is a {<span style=\"color: #0000ff;\"><strong>shiny<\/strong><\/span>} app with three tabs:<\/p>\n<ol>\n<li>Tab 1 shows the player stats over the past 3 years and where they rank compared to other players.<\/li>\n<li>Tab 2 allows the user to compare players in VORP by selecting the players they are interested in.<\/li>\n<li>Tab 3 uses K-Nearest Neighbor to forecast the rest of the player&#8217;s career by identifying the players that are most similar to in regards to how they have performed over time.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-20-at-12.25.09-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1849\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-20-at-12.25.09-PM-1024x510.png\" alt=\"\" width=\"675\" height=\"336\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-20-at-12.25.09-PM-1024x510.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-20-at-12.25.09-PM-300x149.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-20-at-12.25.09-PM-768x383.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-20-at-12.25.09-PM-624x311.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2020\/09\/Screen-Shot-2020-09-20-at-12.25.09-PM.png 1341w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/a><\/p>\n<p>To watch the screen cast, <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.youtube.com\/watch?v=dQd89Rk5q1E&amp;feature=youtu.be\">CLICK HERE<\/a><\/span><\/strong>.<\/p>\n<p>To access our code, <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/github.com\/thebioengineer\/TidyX\/tree\/master\/TidyTuesday_Explained\/028-Nearest_Neighbor_and_ReactiveValues\">CLICK HERE<\/a><\/span><\/strong>.<\/p>\n<p>To see the previous parts of our {<span style=\"color: #0000ff;\"><strong>shiny<\/strong><\/span>} app development series:<\/p>\n<p><strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/optimumsportsperformance.com\/blog\/tidyx-25-intro-to-shiny-apps\/\">Part 0.5<\/a><br \/>\n<a style=\"color: #0000ff;\" href=\"https:\/\/optimumsportsperformance.com\/blog\/tidyx-26-shiny-apps-part-1-creating-an-nba-dashboard\/\">Part 1<\/a><\/span><\/strong><strong><span style=\"color: #0000ff;\"><br \/>\n<a style=\"color: #0000ff;\" href=\"https:\/\/optimumsportsperformance.com\/blog\/tidyx-27-shiny-apps-part-2-adding-tabs-and-improving-ui\/\">Part 2<\/a><\/span><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In installment three of our {shiny} dashboard from scratch series, Ellis Hughes and discuss how to use the K-Nearest Neighbor algorithm to forecast a player&#8217;s career projection for the Value Over Replacement Player (VORP) metric. We then take this analysis and build upon our {shiny} app from the previous two weeks by walking through how [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44],"tags":[],"class_list":["post-1848","post","type-post","status-publish","format-standard","hentry","category-tidyx-screen-cast"],"_links":{"self":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/1848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/comments?post=1848"}],"version-history":[{"count":1,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/1848\/revisions"}],"predecessor-version":[{"id":1850,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/1848\/revisions\/1850"}],"wp:attachment":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/media?parent=1848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/categories?post=1848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/tags?post=1848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}