{"id":3019,"date":"2023-04-17T04:52:52","date_gmt":"2023-04-17T04:52:52","guid":{"rendered":"http:\/\/optimumsportsperformance.com\/blog\/?p=3019"},"modified":"2023-04-17T11:51:45","modified_gmt":"2023-04-17T11:51:45","slug":"tidyx-episode-142-storing-data-in-for-loops-an-example-using-k-fold-cross-validation","status":"publish","type":"post","link":"https:\/\/optimumsportsperformance.com\/blog\/tidyx-episode-142-storing-data-in-for-loops-an-example-using-k-fold-cross-validation\/","title":{"rendered":"TidyX Episode 142: Storing data in for loops &#8211; An example using k-fold cross validation"},"content":{"rendered":"<p><strong>for()<\/strong> loops are a necessary evil &#8211; you probably wont love writing them but they come in handy. I often find myself writing a lot of <strong>for()<\/strong> loops and viewers of our screen cast often have questions about writing <strong>for()<\/strong> loops. This week, <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/twitter.com\/ellis_hughes\">Ellis Hughes<\/a><\/span><\/strong> and I discuss four different approaches to storing your data from a <strong>for()<\/strong> loop so that you can use it for downstream projects (e.g., data models, visualizations, etc.). We do this with an example of creating a <strong>for()<\/strong> loop for k-fold cross validation.<\/p>\n<p>K-fold cross validation is a useful component of the model building process, allowing you to split the data into <em><strong>K<\/strong><\/em> number of folds. Each fold serves as a one time <em>hold-out<\/em> set whereby a model is constructed on the rest of the data and that model is then used to predict on the <em>hold-out<\/em> fold. This continues until each k-fold has been held out and predicted on. The model performance is then compared across each of the folds. This type of iterative approach to model building makes k-fold cross validation a good candidate for a <strong>for()<\/strong> loop.<\/p>\n<p>To watch our screen cast, <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.youtube.com\/watch?v=rgMk6ig6uRo\">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\/142-Storing_Data_From_a_Loop\">CLICK HERE<\/a><\/span><\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>for() loops are a necessary evil &#8211; you probably wont love writing them but they come in handy. I often find myself writing a lot of for() loops and viewers of our screen cast often have questions about writing for() loops. This week, Ellis Hughes and I discuss four different approaches to storing your data [&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-3019","post","type-post","status-publish","format-standard","hentry","category-tidyx-screen-cast"],"_links":{"self":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/3019","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=3019"}],"version-history":[{"count":2,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/3019\/revisions"}],"predecessor-version":[{"id":3021,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/3019\/revisions\/3021"}],"wp:attachment":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/media?parent=3019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/categories?post=3019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/tags?post=3019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}