Skip to content

Instantly share code, notes, and snippets.

@euclidjda
Last active August 29, 2015 14:24
Show Gist options
  • Save euclidjda/404766850665e7b355a3 to your computer and use it in GitHub Desktop.
Save euclidjda/404766850665e7b355a3 to your computer and use it in GitHub Desktop.
Plot the accuracy of a model trained in R with caret through time
library(plyr)
data <- read.table("rdata-10pct-1973-1999.dat",sep = " ", header = TRUE, na.strings="NULL",
colClasses=c(DATE="character",GVKEY="character",MONTH="character"))
x <- data[1:6]
y <- factor(data$LABEL)
preds.train <- predict(mdl,x)
data$preds <- as.numeric(levels(preds.train))[preds.train]
data$correct <- (data$LABEL*data$preds+1)/2
mean(data$correct)
res <- ddply(data,"DATE",summarise,mean=mean(correct),size=length(correct))
plot(res$DATE,res$mean)
ggplot(data = res, aes( DATE, mean )) + geom_point() + scale_x_discrete(breaks = c("197301","198001","199001","199912"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment