GithubHelp home page GithubHelp logo

autonrocs's Introduction

This code can be used to plot Receiver Operating Characteric (ROC) curves. See the example notebook for more information.

General Requirements:

- Sample true labels and classifier predictions must be in a dataframe where each row refers to a different sample. 
- True labels must be binary ({0, 1} or {-1, 1}) with 1 corresponding to the positive class
- True label dataframe(s), prediction dataframe(s), fold dataframe(s), legend label(s), and line color(s) input must be stored in a list. Each list item must correspond to different classifier results to plot.

Directions:

# Import data
truth = [classifier_1_truth, classifier_2_truth]
preds = [classifier_1_predictions, classifier_2_predictions]
folds = [classifier_1_folds, classifier_2_folds]
labels = ['classifier 1', 'classifier 2']
colors = ['blue', 'red']

# Plot ROC curve using bokeh
from roc_curve.plotting import ROC_Curve_bokeh

plt = ROC_Curve_bokeh(axis_label_size='22', axis_tick_size='16', legend_text_size='18')
plt.plot(true_labels=truth, predictions=preds, folds=folds, xrange=(0,1), yrange=(0,1), direction='TPRvsFPR', 
         x_scale='linear', line_width=4, line_dash='solid', line_color=colors, legend_label=labels, 
         legend_location='bottom_right', ci_method='parametric', alpha=0.05, bootstrap_iters=None, random_seed=0)

# Plot ROC curve using matplotlib
from roc_curve.plotting import ROC_Curve_matplotlib

plt = ROC_Curve_matplotlib(axis_label_size='22', axis_tick_size='16', legend_text_size='18')
plt.plot(true_labels=truth, predictions=preds, folds=folds, xrange=(0,1), yrange=(0,1), direction='TPRvsFPR', 
         x_scale='linear', line_width=4, line_dash='solid', line_color=colors, legend_label=labels, 
         legend_location='bottom_right', ci_method='parametric', alpha=0.05, bootstrap_iters=None, random_seed=0,
         save_dir=None)

Confidence Interval Options:

parametric

- Can be used for classifier results obtained from k-fold cross-validation
- The standard error is computed based on the user-defined confidence level (alpha) and the number of k-folds. A 't' distribution is assumed rather than a 'z' distribution as the latter typically requires 'n>30' as one of the normal distribution assumption requirements. A t-distribution approaches a z-distribution for a large number of samples.
- Side Note: k-fold score sets can be joined into one set provided the data meets the assumption that there is no difference in the population TPR and FPR between the k-folds. 

bootstrap (non-parametric)

- Can be used for results where k-folds is None
- A bootstrap confidence interval is computed by resampling the same number of sample predictions and true label values as the original data WITH replacement. The user-defined confidence level is used to identify the empirical quantile values for the confidence interval.

autonrocs's People

Contributors

injuredroman avatar potosnakw avatar

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.