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
{ | |
"name": "flare", | |
"children": [ | |
{ | |
"name": "analytics", | |
"children": [ | |
{ | |
"name": "cluster", | |
"children": [ | |
{"name": "AgglomerativeCluster", "size": 3938}, |
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
mybins = function(x, numbreaks, weights, ordered=T) { | |
if (missing(weights)) x.w = x | |
else x.w = rep(x, times=weights) | |
breaks = quantile(x.w, seq(0,1,length.out=numbreaks+1)) | |
bins = findInterval(x, breaks, rightmost.closed=T) | |
bins.f = factor(bins, levels = 1:numbreaks, ordered=ordered) | |
list(breaks = breaks, bins = bins.f, numbreaks = numbreaks, ordered = ordered) | |
} | |
mybins.assign = function(bins, newx) { |
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
strstrip = function(x) gsub("^\\s+|\\s+$", "", x) |
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
isBinaryVariable = function(x) { | |
apply(x, 2, function(j) { | |
return (identical(range(unique(j)), c(0,1))) | |
}) | |
} | |
scaleBinary = function(j) { | |
p = mean(j) | |
j.sd = sqrt(p*(1-p)) | |
(j - p) / j.sd |
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
myload = function(filename) { | |
tryCatch({ | |
local({ | |
objects = load(filename) | |
if (length(objects) == 1) return (get(objects)) | |
else return (lapply(sapply, get)) | |
}) | |
}, error = function(e) {cat("No such file")}) | |
} |
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
#!/bin/bash | |
if [ $# -lt 3 ] ; | |
then | |
echo "Usage: $0 inputfile output_prefix lines_per_chunk [header=1]" | |
exit | |
fi | |
header=1 | |
if [ $# -eq 4 ] ; |
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
require(data.table) | |
#Note that this permanently modifies test.data | |
hideNewLevels = function(train.data, test.data, replacement=NA, colnames.factor=NULL) { | |
if(is.null(colnames.factor)) colnames.factor = extractFactors(test.data) | |
for (col in colnames.factor) { | |
levels.test = levels(test.data[,get(col)]) | |
levels.train = levels(train.data[,get(col)]) | |
badlevels.indices = which(!levels.test %in% levels.train) |
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
.ls.objects <- function (pos = 1, pattern, 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) | |
obj.prettysize <- sapply(obj.size, function(r) prettyNum(r, big.mark = ",") ) | |
obj.dim <- t(napply(names, function(x) |
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
bootstrapForecast = function(..., newxreglist=NULL, inv.transform=NULL, runs=1000, n.ahead=90, CI.level = .95) { | |
models = list(...) | |
nummodels = length(models) | |
sims = vapply(1:runs, function(i) { | |
sim = vapply(1:nummodels, function(j) { | |
if (is.data.frame(newxreglist)) newxreg = newxreglist | |
else newxreg = newxreglist[[j]] | |
if (!is.null(inv.transform)) { | |
if(is.list(inv.transform)) inv = inv.transform[[j]] | |
else inv = inv.transform |
OlderNewer