Created
March 11, 2015 16:26
-
-
Save stefanthaler/58ac68f3ee1483051dd7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #! /usr/bin/env python | |
| #generate and plot a ROC curve for a classifier using Orange (http://orange.biolab.si/) | |
| #Source Code: https://github.com/biolab/orange/blob/master/Orange/evaluation/scoring.py | |
| import Orange | |
| learners = [Orange.classification.bayes.NaiveLearner(name="bayes"), | |
| Orange.classification.tree.TreeLearner(name="tree"), | |
| Orange.classification.svm.SVMLearnerEasy(name="easySVM")] | |
| #split data to train and test set | |
| data = Orange.data.Table("voting") | |
| split_set = Orange.data.sample.SubsetIndices2(p0=0.8)(data) #random zero / 1 | |
| train_set = data.select(split_set, 0) | |
| test_set = data.select(split_set, 1) | |
| #the magic | |
| results = Orange.evaluation.testing.learn_and_test_on_test_data(learners,train_set, test_set) | |
| curves = Orange.evaluation.scoring.compute_ROC(results) | |
| Orange.evaluation.scoring.plot_ROC("roc.gp", curves, [l.name for l in learners]) | |
| # plot can be displayed by loading it to gnuplot http://people.duke.edu/~hpgavin/gnuplot.html | |
| # > gnuplot | |
| # > load "roc.gp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment