From 5eee8d886d3caace6e9d347a86f965319dc6de37 Mon Sep 17 00:00:00 2001 From: Ivan Molineris Date: Fri, 23 May 2014 15:04:56 +0200 Subject: [PATCH] Added a --quiet option to produce an output more suitable for machine reading --- pyroc.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) mode change 100644 => 100755 pyroc.py diff --git a/pyroc.py b/pyroc.py old mode 100644 new mode 100755 index e5d16f1..dd9bafb --- a/pyroc.py +++ b/pyroc.py @@ -349,9 +349,6 @@ def _calculate_counts(self,pos_data,neg_data): if __name__ == '__main__': - print "PyRoC - ROC Curve Generator" - print "By Marcel Pinheiro Caraciolo (@marcelcaraciolo)" - print "http://aimotion.bogspot.com\n" from optparse import OptionParser parser = OptionParser() @@ -359,10 +356,15 @@ def _calculate_counts(self,pos_data,neg_data): parser.add_option("-n", "--max fp", dest = "fp_n", default=0, help= "Maximum false positives to calculate up to (for partial AUC).") parser.add_option("-p","--plot", action="store_true",dest='plotFlag', default=False, help="Plot the ROC curve (matplotlib required)") parser.add_option("-t",'--title', dest= 'ptitle' , default='' , help = 'Title of plot.') + parser.add_option("-q",'--quiet', dest= 'quiet', action='store_true', default=False , help = 'Do not print informative text') (options,args) = parser.parse_args() - + if not options.quiet: + print "PyRoC - ROC Curve Generator" + print "By Marcel Pinheiro Caraciolo (@marcelcaraciolo)" + print "http://aimotion.bogspot.com\n" + if (not options.origFile): parser.print_help() exit() @@ -370,13 +372,12 @@ def _calculate_counts(self,pos_data,neg_data): df_data = load_decision_function(options.origFile) roc = ROCData(df_data) roc_n = int(options.fp_n) - print "ROC AUC: %s" % (str(roc.auc(roc_n)),) - print 'Standard Error: %s' % (str(roc.calculateStandardError(roc_n)),) + print "#ROC AUC:\t%s" % (str(roc.auc(roc_n)),) + print '#Standard Error:\t%s' % (str(roc.calculateStandardError(roc_n)),) - print '' for pt in roc.derived_points: print pt[0],pt[1] if options.plotFlag: roc.plot(options.ptitle,True,True) - \ No newline at end of file +