Skip to content

Instantly share code, notes, and snippets.

@mikejs
Created July 11, 2010 03:45
Show Gist options
  • Save mikejs/471265 to your computer and use it in GitHub Desktop.
Save mikejs/471265 to your computer and use it in GitHub Desktop.
train <- read.csv("~/code/informs/TrainingData.csv", row.names=1, header=TRUE)
test <- read.csv("~/code/informs/ResultData.csv", row.names=1, header=TRUE)
for (col in c("Variable142OPEN", "Variable142LOW", "Variable142HIGH",
"Variable142LAST", "Variable158OPEN", "Variable158LOW",
"Variable158HIGH", "Variable158LAST")) {
train[col] <- NULL
test[col] <- NULL
}
train[is.na(train)] <- 0.0
test[is.na(test)] <- 0.0
tot <- NULL
for (i in 1:10) {
sam <- train[sample(1:nrow(train), replace=TRUE),]
mod <- glm(TargetVariable ~ ., data=sam, family=binomial(link="logit"))
if (is.null(tot)) {
tot <- predict(mod, test, type="response")
} else {
tot <- tot + predict(mod, test, type="response")
}
}
avg <- tot / 10
avg <- as.data.frame(avg)
avg <- avg + runif(nrow(avg), -0.05, 0.05)
avg[avg > 1] <- runif(length(avg[avg > 1]), 0.95, 1.0)
avg[avg < 0] <- runif(length(avg[avg < 0]), 0.0, 0.05)
write.csv(avg, "~/out.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment