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
#include <stdio.h> | |
#include <stdlib.h> | |
#define N 100 | |
#define B0 100 | |
#define R 1000000 | |
int main() { | |
int b[N], rec[N]; | |
for (int i=0; i<N; i++) b[i] = B0; |
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
library(caret) | |
library(readr) | |
library(ROCR) | |
set.seed(123) | |
d <- read_csv("https://raw.githubusercontent.com/szilard/teach-data-science-UCLA-master-appl-stats/master/wk-06-ML/data/airline100K.csv") |
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
#### h2o | |
library(h2o) | |
h2o.init(max_mem_size = "50g", nthreads = -1) | |
dx_train <- h2o.importFile("train-1m.csv") | |
dx_test <- h2o.importFile("test.csv") | |
Xnames <- names(dx_train)[which(names(dx_train)!="dep_delayed_15min")] |
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
library(data.table) | |
n <- 2e9 | |
m <- 1e9 | |
system.time( d <- data.table(x = sample(m, n, replace=TRUE), y = runif(n)) ) | |
# user system elapsed | |
# 103.843 8.255 112.242 | |
system.time( dm <- data.table(x = sample(m)) ) | |
# user system elapsed | |
# 47.298 1.860 49.288 |
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
library(h2o) | |
h2o.init(nthreads = -1) | |
dx_train <- h2o.importFile("https://s3.amazonaws.com/benchm-ml--main/train-1m.csv") | |
system.time({ | |
md_10 <- h2o.gbm(x = 1:(ncol(dx_train)-1), y = ncol(dx_train), training_frame = dx_train, | |
model_id = "airline_depth10", |
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
library(h2o) | |
h2o.init(max_mem_size = "20g", nthreads = -1) | |
# R is connected to the H2O cluster: | |
# H2O cluster uptime: 1 seconds 704 milliseconds | |
# H2O cluster version: 3.8.2.8 | |
# H2O cluster name: H2O_started_from_R_szilard_lcr105 | |
# H2O cluster total nodes: 1 | |
# H2O cluster total memory: 17.78 GB |
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
## allocate <1TB first, stuff works | |
> x <- 1:1.2e11 | |
> gc() | |
used (Mb) gc trigger (Mb) max used (Mb) | |
Ncells 214403 11.5 4.60000e+05 24.6 350000 18.7 | |
Vcells 120000397293 915530.4 1.72801e+11 1318366.9 120000398080 915530.4 | |
> system("echo 1") | |
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
> system.time(x <- 1:1e11) | |
user system elapsed | |
221.491 210.466 432.030 | |
> object.size(x)/1e9 | |
800.00000004 bytes | |
> system.time(sum(x)) | |
user system elapsed | |
145.913 78.183 230.063 |
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
system.time(z <- 1:1e9) | |
system.time(d <- data.frame(x = 1:1e9)) | |
system.time(d$y <- 1:1e9) | |
system.time(d$z <- z) | |
system.time(d$x[1] <- 0L) | |
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
sqlite vs R's data.table | |
TLDR; sqlite (:memory:) 250 sec data.table 7 sec | |
data: 100 million rows, 1 million groups | |
generated by: https://github.com/szilard/benchm-databases/blob/master/0-gendata.txt | |