Skip to content

Instantly share code, notes, and snippets.

View ck37's full-sized avatar

Chris Kennedy ck37

View GitHub Profile
@ledell
ledell / h2o_rf_sigopt_demo_iris.R
Last active June 3, 2017 04:56
Demo of how to use the SigOpt API with H2O in R
# Set API Key
Sys.setenv(SIGOPT_API_TOKEN="HERE")
# Start a local H2O cluster for training models
library(h2o)
h2o.init(nthreads = -1)
# Load a dataset
data(iris)
y <- "Species"
@mrecos
mrecos / Purrr Grid Search Parallel.R
Last active December 24, 2017 20:46
A bit of code for conducting parallelized random grid-search of randomForest hyperparameters using purrr::map() and futures (for multicore/multisession). This is a bit of a proof-of-concept as there are plenty of ways to iterate over a grid and do CV. Also, especially with randomForest, this is very memory inefficient. However, the approach may …
### ------- Load Packages ---------- ###
library("purrr")
library("future")
library("dplyr")
library("randomForest")
library("rsample")
library("ggplot2")
library("viridis")
### ------- Helper Functions for map() ---------- ###
# breaks CV splits into train (analysis) and test (assessmnet) sets
@JohnMount
JohnMount / confEc2RServer.bash
Last active September 6, 2021 09:49
Configure an Amazon EC2 instance to serve a tunneled RStudio Server instance (from a Unix client)
#!/bin/bash
# on local
pempath="$1"
ec2target="$2"
ssh -T -i "${pempath}" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${ec2target} << 'EOBLOCK'
# on remote machine
sudo apt-get -y update
sudo apt-get -y upgrade
@doraneko94
doraneko94 / roc_auc_ci.py
Last active January 4, 2025 08:56
Calculating confidence interval of ROC-AUC.
from sklearn.metrics import roc_auc_score
from math import sqrt
def roc_auc_ci(y_true, y_score, positive=1):
AUC = roc_auc_score(y_true, y_score)
N1 = sum(y_true == positive)
N2 = sum(y_true != positive)
Q1 = AUC / (2 - AUC)
Q2 = 2*AUC**2 / (1 + AUC)
SE_AUC = sqrt((AUC*(1 - AUC) + (N1 - 1)*(Q1 - AUC**2) + (N2 - 1)*(Q2 - AUC**2)) / (N1*N2))
@aditya-malte
aditya-malte / smallberta_pretraining.ipynb
Created February 22, 2020 13:41
smallBERTa_Pretraining.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sellorm
sellorm / render_with_jobs.R
Created April 15, 2021 20:54
Render an Rmarkdown document in the RStudio jobs pane.
render_with_jobs <- function(){
rstudioapi::verifyAvailable()
jobs_file <- tempfile(tmpdir = "/tmp", fileext = ".R")
rmd_to_render <- rstudioapi::selectFile(caption = "Choose an Rmd file...",
filter = "Rmd files (*.Rmd)")
if (is.null(rmd_to_render)){
stop("You must choose an Rmd file to proceed!")
}
cat(paste0('rmarkdown::render("', rmd_to_render, '")'), file = jobs_file)
rstudioapi::jobRunScript(path = jobs_file,