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(ggplot2) | |
library(dplyr) | |
library(qs2) | |
LEN <- 2^30 / 8 | |
set.seed(314156); data <- rnorm(LEN) + seq(1,LEN,1) # 1 GB | |
qs_send <- 4.40 # seconds | |
serialize_send <- 1.94 | |
qs_size <- length(qs_serialize(data, compress_level = 1, nthreads=4)) # 852 MB | |
serialize_size <- length(serialize(data, connection = NULL)) # 1 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
total_time <- Sys.time() | |
suppressMessages(library(Rcpp)) | |
suppressMessages(library(dplyr)) | |
suppressMessages(library(data.table)) | |
suppressMessages(library(qs)) | |
suppressMessages(library(stringfish)) | |
options(warn = 1) | |
do_gc <- function() { |
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(stringi) # devtools::install_github("traversc/stringi") | |
library(tictoc) | |
enwik8 <- readLines("~/Downloads/enwik8", warn = F) | |
search <- c("Wikipedia", "^.") | |
replace <- c("Encyclopedia", "") | |
tic("WITHOUT alt rep") | |
stri_use_alt_rep(FALSE); result <- stri_replace_all_regex(enwik8, search, replace, vectorize_all = F) | |
toc() |
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 <atomic> | |
#include <thread> | |
#include <Rcpp.h> | |
#include <R_ext/Print.h> | |
using namespace Rcpp; | |
class simple_progress { | |
private: | |
const size_t max; | |
std::atomic<size_t> counter; |
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(qs) | |
library(data.table) | |
library(dplyr) | |
library(ggplot2) | |
library(fst) | |
library(patchwork) | |
library(ggformula) | |
library(hrbrthemes) | |
library(Rcpp) | |
library(trqwe) |
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 <sys/types.h> | |
#include <sys/stat.h> | |
#include <io.h> | |
#include <fcntl.h> | |
#include <string.h> | |
#include <array> | |
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::plugins(cpp11)]] |
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 <cerrno> | |
#include <fcntl.h> | |
#include <cstdio> | |
#include <unistd.h> | |
#include <string.h> | |
#include <array> | |
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::plugins(cpp11)]] |
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 <iostream> | |
#include "altrepisode.h" | |
#include <string> | |
#include <vector> | |
std::string getRandomStrings(int seed, int len = 30) { | |
std::srand(static_cast<unsigned int>(seed)); | |
static const char alphanum[] = | |
"0123456789" | |
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
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
fastROC <- function(probs, class) { | |
class_sorted <- class[order(probs, decreasing=T)] | |
TPR <- cumsum(class_sorted) / sum(class) | |
FPR <- cumsum(class_sorted == 0) / sum(class == 0) | |
return(list(tpr=TPR, fpr=FPR)) | |
} | |
# Helpful function adapted from: https://stat.ethz.ch/pipermail/r-help/2005-September/079872.html | |
fastAUC <- function(probs, class) { | |
x <- probs |