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") | |
| 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
| 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
| 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
| 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
| sudo apt-get update | |
| sudo apt-get install -y build-essential git libatlas-base-dev libopencv-dev | |
| git clone --recursive https://github.com/dmlc/mxnet | |
| cd mxnet; | |
| cp make/config.mk . | |
| #add CUDA options | |
| echo "USE_CUDA=1" >>config.mk |
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("ggplot2") | |
| library("mxnet") | |
| plot_mxmodel <- function(model, data) { | |
| x <- seq(from = min(data), to = max(data), length.out = 500) | |
| d2 <- as.matrix(expand.grid(x, x)) | |
| mx_pred <- predict(model, d2) |
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
| # Instantiate local CRAN | |
| localCRAN <- path.expand("QRAN") | |
| dir.create(localCRAN) | |
| contribDir <- file.path(localCRAN, "src", "contrib") | |
| dir.create(contribDir, recursive = TRUE) | |
| rVersion <- paste(unlist(getRversion())[1:2], collapse = ".") | |
| binPaths <- list( |
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
| generate_fks <- function(N) { | |
| fki <- log(N + 1) | |
| fks <- c(fki) | |
| for (i in seq(N)) { | |
| fki <- log(exp(fki) - fki) | |
| fks <- c(fks, fki) | |
| } | |
| fks |