Giter Site home page Giter Site logo

sage-bionetworks / challengescoring Goto Github PK

View Code? Open in Web Editor NEW
3.0 11.0 0.0 141 KB

This R package provides scoring mechanisms for computational challenges and implements the bayesBootLadderBoot approach for avoiding test data leakage.

License: Apache License 2.0

R 100.00%
dream challenges bootstrapping-statistics

challengescoring's Introduction

challengescoring

This R package provides scoring mechanisms for computational challenges and implements the bayesBootLadderBoot approach for avoiding test data leakage.

Installation

remotes::install_github("Sage-Bionetworks/challengescoring@master")

Usage

View vignettes.

challengescoring's People

Contributors

allaway avatar andrewelamb avatar thomasyu888 avatar vpchung avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

challengescoring's Issues

refactor package to make it easier to reuse scoring functions directly in challenge pipeline

challengescoring functions were written with post-challenge analysis in mind.

most challengescoring score functions are written as score_fun(prediction_vector, gold_vector)
most challenge pipeline scoring functions are written as score_fun(path_to_pred, path_to_gold)

It would be much easier if the scoring functions were easy to both bootstrap as well as call package functions in the challenge pipeline.

However, a small challenge with this is that the scoring functions are called 1000's of times when bootstrapping, so if they are reading in the csv each time, that could be a problem. Additionally, for bootstrapping, the resampling needs to be paired across all prediction files tested, so the resampling step needs to happen outside the scoring function, not inside. This is how it is currently implemented, but would be harder if the scoring function is reading from a path rather than a list of resampled prediction dfs.

Issue with challengescoring vignette

I'm getting this error trying to get the vignette to run:

library(survival)
goldStandard <- Surv(d.time, death) %>% as.character() %>% as.data.frame() %>% magrittr::set_colnames(c("gold"))
predictions <- age_new %>% as.data.frame() %>% magrittr::set_colnames(c("pred"))
prevPredictions <- age_previous %>% as.data.frame() %>% magrittr::set_colnames(c("pred"))

bootLadderBoot(predictions = predictions,
               predictionColname = "pred",
               prevPredictions = prevPredictions,
               goldStandard = goldStandard,
               goldStandardColname = "gold",
               scoreFun = c_statistic,
               verbose = T)

Error: `by` required, because the data sources have no common variables
16.
stop(fallback)
15.
signal_abort(cnd)
14.
.abort(text)
13.
glubort(fmt_args(args), ..., .envir = .envir)
12.
bad_args("by", "required, because the data sources have no common variables")
11.
common_by.NULL(by, x, y)
10.
common_by(by, x, y)
9.
full_join.tbl_df(tbl_df(x), y, by = by, copy = copy, ...)
8.
full_join(tbl_df(x), y, by = by, copy = copy, ...)
7.
as.data.frame(full_join(tbl_df(x), y, by = by, copy = copy, ...))
6.
full_join.data.frame(goldStandardDF, predictionsDF)
5.
dplyr::full_join(goldStandardDF, predictionsDF)
4.
eval(lhs, parent, parent)
3.
eval(lhs, parent, parent)
2.
dplyr::full_join(goldStandardDF, predictionsDF) %>% dplyr::full_join(prevPredictionsDF) %>% dplyr::select_(goldStandardColname, predictionColname, "prevpred") %>% purrr::set_names("gold", "pred", "prevpred") at bootstrap.R#71
1.
bootLadderBoot(predictions = predictions, predictionColname = "pred", prevPredictions = prevPredictions, goldStandard = goldStandard, goldStandardColname = "gold", scoreFun = c_statistic, verbose = T)

Add readme

Should add readme about this repository. Should include

  • What this package is
  • Contributing guide
  • how to run tests

Gustavo's Integrated ROC/PR

Not sure what algorithm for ROC is used, but Gustavo like the integrated AUROC/AUPR. I implemented a version in R that someone could cleanup and add if necessary.

add validation functions

I've reused a lot of validation functions. seems like these could be easily turned into package functions

Examples:


trim_vec <- function(vec, trim = 10){
  if(length(vec) > trim){
    vec <- vec[1:trim]
    vec <- as.character(vec)
    vec[trim+1] <- '...'
  }else{
    vec
  }
}

validate <- function(prediction_path, template_path){
  
  pred <- readr::read_csv(prediction_path)
  temp <- readr::read_csv(template_path)
  
  ###configure validation
  ncol_req <- ncol(temp)
  nrow_req <- nrow(temp)
  colnames_req <- colnames(temp)
  target_ids <- unique(temp$target)
  
  errs <- list()

  if(ncol(pred)<ncol_req){
    errs["ncol_short"] <- paste0("Prediction file is missing cols. Only ", ncol(pred), " cols detected.")
  }
  
  if(ncol(pred)>ncol_req){
    errs["ncol_long"] <- paste0("Prediction file has extra  cols ", ncol(pred), " cols detected.")
  }
  
  if(nrow(pred)<nrow_req){
    errs["nrow_short"] <- paste0("Prediction file is missing rows Only ", nrow(pred), " rows detected.")
  }
  
  if(nrow(pred)>nrow_req){
    errs["nrow_long"] <- paste0("Prediction file has extra  rows ", nrow(pred), " rows detected.")
  }
  
  if(isTRUE(colnames(pred) %in% temp)){
    errs["colnames"] <- paste0("Column names are not correct. Column names must be ", cat(colnames_req))
  }
  
  if(!(all(pred[-1] >= 0) & all(pred[-1] <= 1))){
    errs["wrong_range"] <- paste0("Confidence values are not between 0 and 1.")
  }
  
  if(!all(apply(pred[-1], 1:2, is.numeric))){
    errs["non_numeric"] <- paste0("Predictions are not all numeric values.")
  }
  
  if(any(!pred$target %in% target_ids)){
    invalid <- unique(pred$target[!pred$target %in% target_ids]) %>% trim_vec()
    errs["non_target"] <- paste0("Invalid target identifiers were included in your prediction file (up to 10 displayed): ", invalid)
  }
  
  return(errs)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.