Skip to content

Instantly share code, notes, and snippets.

View epijim's full-sized avatar

James Black epijim

View GitHub Profile
@epijim
epijim / weight.ipynb
Created February 18, 2016 07:46 — forked from anixdorf/weight.ipynb
Personal IPython Weight Notebook (http://nbviewer.ipython.org/gist/anixdorf/9769238)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# go to https://github.com/FortAwesome/Font-Awesome/tree/master/webfonts
# and install fa-solid-900.ttf, fa-regular-400.ttf and fa-brands-400.ttf
# then run extrafont::font_import()
library(tidyverse)
library(ggplot2)
library(waffle)
extrafont::loadfonts()
# From LEAP supplemental appendix
@epijim
epijim / c-index.R
Created August 23, 2022 08:27
Score a c-index
get_cindex <- function(
predictions = NULL,
test_truth = NULL
){
start_time <- Sys.time()
# Prep data
predictions_names <- c("patientid","prediction" )
if(!identical(predictions_names,names(predictions))) stop(paste(
@epijim
epijim / score_auc.R
Last active September 8, 2022 12:52
score_auc <- function(
predictions,
truth
){
if (!"patientid" %in% names(predictions)) stop("patientid missing from predictions")
if (!"prediction" %in% names(predictions)) stop("prediction missing from predictions")
if (!"patientid" %in% names(truth)) stop("patientid missing from truth")
if (!"has_long_covid_diag" %in% names(truth)) stop("has_long_covid_diag missing from truth")
score_cindex <- function(
zip_path, # zip file path
truth # in memory R object
){
library("pec") # pec functions don't work without the lib loaded :(
files_present <- zip::zip_list(zip_path)$filename
# Check files present
geom_glowing_area <- function(
alpha = 1,
size = 1.5,
glow_alpha = 0.05,
layers = 10,
glow_size = .65){
geoms <- list(ggplot2::geom_area(alpha = .5, position = "identity",color = "#08f7fe"))
for(i in (layers+1):1){