This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lift1 <- caret::lift(factor(test_data$dep_var) ~ model2.2.1_v3$predict(test_data), class = "1") | |
png("~/tmp/output/model2.2.1/validation_v3/lift_chart.png") | |
xyplot(lift1) | |
dev.off() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rlist | |
# http://cran.r-project.org/web/packages/rlist/rlist.pdf | |
default <- list(a = 1, b = 2) | |
new <- list(b = 3) | |
list.merge(default, new) #new would overwrite default | |
list.join(default, new, "b") | |
# package::ff | |
# http://cran.r-project.org/web/packages/ff/index.html | |
# doing complicated operations on disk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout somecommit #revert back to an older commit | |
git stash #stash changes | |
git checkout -b new_branch #spin off to a new branch | |
git stash pop # restore the changes to the new branch | |
git add . | |
git commit -a -m | |
git push origin new_branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Multiple plot function | |
# | |
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects) | |
# - cols: Number of columns in layout | |
# - layout: A matrix specifying the layout. If present, 'cols' is ignored. | |
# | |
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), | |
# then plot 1 will go in the upper left, 2 will go in the upper right, and | |
# 3 will go all the way across the bottom. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system(paste('s3cmd ls ', s3mpi:::s3path(), 'models/*', sep = ''), intern = TRUE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
restoreLevels <- function(datum, model_varnames, model_levels, klasses) { | |
#model_varnames = .GBM_model$var.names, | |
#model_levels = .GBM_model$var.levels, | |
#klasses = attr(.GBM_model$Terms, 'dataClasses')) { | |
grab_levels <- function(colname) { | |
level_index <- which(model_varnames == colname) | |
if (length(level_index) == 0) return(NULL) | |
model_levels[[level_index]] | |
} | |
.datum <<- datum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
null_to_na <- function(obj) { | |
df <- as.data.frame(t(as.data.frame(lapply(lapply(obj, lapply, function(x)ifelse(is.null(x), NA, x)), unlist)))) | |
rownames(df) <- NULL | |
df | |
} | |
dst <- rubyread('defaults_source_tier') | |
dst2 <- null_to_na(dst) | |
colnames(dst2) <- c('loan_id', 'dep_var', 'source', 'tier', 'created_at') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session?rq=1 | |
.ls.objects <- function (pos = 1, pattern, order.by, | |
decreasing=FALSE, head=FALSE, n=5) { | |
napply <- function(names, fn) sapply(names, function(x) | |
fn(get(x, pos = pos))) | |
names <- ls(pos = pos, pattern = pattern) | |
obj.class <- napply(names, function(x) as.character(class(x))[1]) | |
obj.mode <- napply(names, mode) | |
obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class) | |
obj.size <- napply(names, object.size) |
NewerOlder