Skip to content

Instantly share code, notes, and snippets.

@vitillo
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitillo/bb0ed9788bd4283a6196 to your computer and use it in GitHub Desktop.
Save vitillo/bb0ed9788bd4283a6196 to your computer and use it in GitHub Desktop.
Add-on startup analysis.
library(dplyr)
library(reshape)
library(doMC)
library(caret)
trim.leading <- function (x) sub("^\\s+", "", x)
trim.trailing <- function (x) sub("\\s+$", "", x)
trim <- function (x) gsub("^\\s+|\\s+$", "", x)
registerDoMC(8)
addons <- read.csv("~/Downloads/dataset.csv")
# Partition the dataset into training and test set
set.seed(42)
data_partition <- createDataPartition(y = addons$startup, p = 0.80, list = F)
training <- addons[data_partition,]
testing <- addons[-data_partition,]
ctrl <- trainControl(method = "repeatedcv", repeats=10)
glm_model <- train(startup ~ ., data=training, method="glm", trControl=ctrl)
prediction <- predict(glm_model, testing)
R2(prediction, testing$startup)
RMSE(prediction, testing$startup)
coefs <- data.frame(coef(summary(glm_model)))
coefs$addon <- row.names(coefs)
coefs$addon <- trim(gsub("\\.", " ", coefs$addon))
slow_addons <- coefs %.% arrange(Estimate) %.% filter(Estimate > 0, Pr...t.. < 0.01, addon != "(Intercept)")
ggplot(slow_addons, aes(factor(addon, levels=unique(addon)), Estimate)) +
geom_point() +
geom_errorbar(width=.1, aes(ymin=Estimate-Std..Error, ymax=Estimate+Std..Error)) +
coord_flip() +
scale_y_continuous(name="Startup time overhead in ms") + scale_x_discrete(name ="Add-on") +
theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment