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
| library("mlbench") | |
| library("gbm") | |
| library("ggplot2") | |
| get_spiral_df <- function(N, cycles, sd) { | |
| spiral_data <- mlbench.spirals(N, cycles, sd) | |
| data.frame(x = spiral_data$x[, 1], | |
| y = spiral_data$x[, 2], | |
| class = as.numeric(spiral_data$classes) - 1) |
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
| import itertools | |
| import numpy as np | |
| from collections import Counter | |
| def person_says_no(possibilities): | |
| uniqueness = Counter([d.values()[0] | |
| for d in possibilities]).items() | |
| impossibilities = [x for (x, count) in uniqueness if count == 1] |
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
| strip_glm <- function(cm) { | |
| cm$y = c() | |
| cm$model = c() | |
| cm$residuals = c() | |
| cm$fitted.values = c() | |
| cm$effects = c() | |
| cm$qr$qr = c() | |
| cm$linear.predictors = c() | |
| cm$weights = c() |
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
| strip_glm <- function(cm) { | |
| cm$y = c() | |
| cm$model = c() | |
| cm$residuals = c() | |
| cm$fitted.values = c() | |
| cm$effects = c() | |
| cm$qr$qr = c() | |
| cm$linear.predictors = c() | |
| cm$weights = c() |
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
| library("data.table") | |
| fread("a,b\n1,T\n1,T\n1,T\n1,T\n1,T\n2,C\n") | |
| # a b | |
| # 1: 1 1 | |
| # 2: 1 1 | |
| # 3: 1 1 | |
| # 4: 1 1 | |
| # 5: 1 1 |
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
| library("data.table") | |
| library("xgboost") | |
| library("Matrix") | |
| generate_data <- function(N) { | |
| data.table( | |
| response = as.numeric(runif(N) > 0.8), | |
| float1 = rnorm(N, 3, 3)) | |
| } |
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
| library("data.table") | |
| library("xgboost") | |
| library("Matrix") | |
| generate_data <- function(N) { | |
| data.table( | |
| response = as.numeric(runif(N) > 0.8), | |
| int1 = round(rnorm(N, 3, 3)) | |
| ) |
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
| library("data.table") | |
| library("xgboost") | |
| library("Matrix") | |
| generate_data <- function(N) { | |
| data.table( | |
| response = as.numeric(runif(N) > 0.8), | |
| int1 = round(rnorm(N, 3, 3)), | |
| int2 = round(rnorm(N, 3, 3)), |
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
| library("igraph") | |
| library("stringi") | |
| library("magrittr") | |
| generate_bridge_df <- function(nrow, ncol) { | |
| this_layer <- generate_layer(ncol) | |
| first_connections <- data.frame(from = "Northside", | |
| to = get_layer_vertices(this_layer)) | |
| all_bridges <- rbind(first_connections, this_layer) |
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
| library("Rcpp") | |
| library("microbenchmark") | |
| simulate_throws <- cppFunction(' | |
| double simulate_throw(NumericVector start, int nthrows, int trials) { | |
| int trials_so_far = 0; | |
| int final_throw_successes_so_far = 0; | |
| int hits_so_far = 0; | |
| int nstart = start.size(); |