Skip to content

Instantly share code, notes, and snippets.

View Laurae2's full-sized avatar

Laurae Laurae2

View GitHub Profile
@Laurae2
Laurae2 / matrix_size.R
Created December 24, 2018 21:05
Matrix size
set.seed(1)
N <- 500000
p <- 100
pp <- 25
X <- matrix(runif(N * p), ncol = p)
betas <- 2 * runif(pp) - 1
sel <- sort(sample(p, pp))
m <- X[, sel] %*% betas - 1 + rnorm(N)
y <- rbinom(N, 1, plogis(m))
@Laurae2
Laurae2 / xgboost_GPU_RAM_usage.R
Last active December 24, 2018 21:34
RAM usage of xgboost GPU in R
library(xgboost)
set.seed(1)
N <- 1000000
p <- 100
pp <- 25
X <- matrix(runif(N * p), ncol = p)
betas <- 2 * runif(pp) - 1
sel <- sort(sample(p, pp))
m <- X[, sel] %*% betas - 1 + rnorm(N)
@Laurae2
Laurae2 / benchmark_xgb_lgb_HIGGS.R
Created March 29, 2020 14:16
Benchmark xgboost and LightGBM using HIGGS dataset in R
library(xgboost)
library(lightgbm)
library(data.table)
setwd("/home/laurae/Documents/R/GBM-perf")
n_threads <- 16
data <- fread("HIGGS.csv")
labels <- data$V1
@Laurae2
Laurae2 / lightgbm_cuda_R_on_thin_ice.Rmd
Last active September 25, 2020 20:38
Install LightGBM with CUDA on R (walk on thin ice)
Walk on thin ice in R for gcc-7/g++-7 + CUDA 10.0.130
Note: OpenCL can run on Single Precision (gpu_use_dp = FALSE) or Double Precision (gpu_use_dp = TRUE) whereas CUDA is strictly Double Precision in LightGBM.
--
STEP 1: HACK IN SOME FILES
Hack in the following:
```
@Laurae2
Laurae2 / date_conversion_benchmark.md
Created December 8, 2020 21:38
R date conversion benchmark copy pasta

Code:

library(anytime)
library(flipTime)
library(data.table)

set.seed(1)
system.time({
  some_dates <- as.Date("2020-12-31") - sample(40000, 1e7, TRUE)