Skip to content

Instantly share code, notes, and snippets.

View kkraoj's full-sized avatar

Krishna Rao kkraoj

View GitHub Profile
```{r first separate data into folds before choosing features}
# train the model on training set
# Leave out fold
accuracy.rates <- c()
for (itr in seq_len(folds)){
# Note: since input features are already random, no need to shuffle the data
# before creating folds. But ideally, examples need to be shuffled before
# creating folds to get rid of recording/data collecting bias
@kkraoj
kkraoj / cv_wrong.rmd
Last active July 11, 2019 07:28
Wrong and right way to do CV
```{r setup, include=FALSE}
rm(list=ls())
knitr::opts_chunk$set(echo = TRUE)
library(caret)
library(ggplot2)
```
# Cross validation Example: The wrong way and the right way