This file contains 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
sudo aptitude install python3-setuptools | |
sudo apt-get install python3-dev libzmq3-dev libcurl4-openssl-dev | |
https://github.com/jupyter/jupyterhub.git | |
cd jupyterhub | |
sudo apt-get install npm nodejs-legacy | |
sudo npm install -g configurable-http-proxy | |
sudo easy_install3 pip |
This file contains 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
hashStrings = function(x) { | |
sapply(x, function(i) { | |
sprintf("hash_%s", paste0(charToRaw(i), collapse="")) | |
}) | |
} | |
unhashStrings = function(x) { | |
sapply(x, function(i) { | |
i = gsub("hash_", "", i) | |
i.split = strsplit(i, "")[[1]] |
This file contains 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
write.libsvm = function(data, filename= "out.dat", class = 1) { | |
out = file(filename) | |
writeLines(apply(data, 1, function(X) paste(X[class],apply(cbind(which(X!=0)[-class], X[which(X!=0)[-class]]), 1, paste, collapse=":"), collapse=" ") ), out) | |
close(out) | |
} | |
#' x should be a model matrix | |
#' y is a response vector | |
write.vw = function(data, outcomeName, weightName = '', classification=F, file = 'vw.txt') { | |
This file contains 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
#Getting sigopt to run on Ubuntu | |
sudo apt-get install gcc-multilib | |
wget http://ftp.gnu.org/gnu/glpk/glpk-4.39.tar.gz | |
tar -xzf glpk-4.39.tar.gz | |
cd glpk-4.39/ | |
./configure | |
make | |
sudo make install | |
LD_LIBRARY_PATH=/usr/local/lib |
This file contains 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
wget http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-2.1.0-Linux-x86_64.sh | |
bash Anaconda-2.1.0-Linux-x86.sh | |
#http://thomassileo.com/blog/2012/11/19/setup-a-remote-ipython-notebook-server-with-numpyscipymaltplotlibpandas-in-a-virtualenv-on-ubuntu-server/ |
This file contains 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 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
dbBuildTableDefinition.hive = | |
function (databasename, tablename, df, field.types = NULL, s3path) | |
{ | |
if (!is.data.frame(df)) | |
df <- as.data.frame(df) | |
if (is.null(field.types)) { | |
field.types <- lapply(df, hiveDataType) | |
} | |
flds <- paste(names(field.types), field.types) | |
base = sprintf("CREATE EXTERNAL TABLE %s.%s |
This file contains 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
plotCoefs = function(model, nonzero = T, subset.condition, ...) { | |
stopifnot(require(ggplot2)) | |
coefs = coef(model)[,1] | |
coef.labels = attr(coefs, "names") | |
isLogistic = model$name == "Binomial Deviance" | |
if (isLogistic) coefs = exp(coefs) | |
coefs.df = data.frame(label = coef.labels, value = coefs) | |
coefs.df = coefs.df[order(coefs.df$value),] | |
coefs.df$label = factor(coefs.df$label, levels = coefs.df$label) |
This file contains 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
sudo apt-get install libcurl4-openssl-dev | |
install.packages(c('RCurl', 'jsonlite')) |
This file contains 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
facetAdjust <- function(x, pos = c("up", "down")) | |
{ | |
pos <- match.arg(pos) | |
p <- ggplot_build(x) | |
gtable <- ggplot_gtable(p); dev.off() | |
dims <- apply(p$panel$layout[2:3], 2, max) | |
nrow <- dims[1] | |
ncol <- dims[2] | |
panels <- sum(grepl("panel", names(gtable$grobs))) | |
space <- ncol * nrow |
NewerOlder