Module Expr Str Import alias Import alias TryExcept body Import alias handlers ExceptHandler body Print Str Print Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Num Num Num Num Num body Assign NameStore ListComp TupleLoad Num Call AttributeLoad NameLoad attr NameLoad NameLoad comprehension NameStore Call NameLoad BinOpDiv NameLoad Num Assign NameStore ListComp TupleLoad Num Call AttributeLoad NameLoad attr NameLoad NameLoad comprehension NameStore Call NameLoad BinOpDiv NameLoad Num Return BinOpAdd NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str NameLoad NameLoad body Expr Str Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Num Num BinOpAdd NameLoad Num Expr Call AttributeLoad NameLoad attr TupleLoad Num Num Expr Call AttributeLoad NameLoad attr TupleLoad Num Num Expr Call AttributeLoad NameLoad attr ListLoad Expr Call AttributeLoad NameLoad attr ListLoad If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str If UnaryOpNot NameLoad body Assign NameStore ListComp Str comprehension NameStore NameLoad Expr Call AttributeLoad NameLoad attr Num Num SubscriptLoad NameLoad Index NameLoad keyword Num Expr Call AttributeLoad NameLoad attr ListComp SubscriptLoad NameLoad Index Num comprehension NameStore AttributeLoad NameLoad attr ListComp SubscriptLoad NameLoad Index Num comprehension NameStore AttributeLoad NameLoad attr Str keyword Num Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad Str Str Str Str Str Str Assign NameStore Str Assign NameStore Str Assign NameStore ListLoad Str Str Str Assign NameStore ListLoad For NameStore NameLoad body If CompareNotIn AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse While NameLoad body If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr If CompareNotIn NameLoad NameLoad body Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Break orelse Assign NameStore Call AttributeLoad Str attr BinOpAdd BinOpAdd Call AttributeLoad NameLoad attr NameLoad Num Call AttributeLoad NameLoad attr NameLoad Num Call AttributeLoad NameLoad attr NameLoad Num If CompareNotIn NameLoad NameLoad body Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Break decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Str NameLoad NameLoad NameLoad body Expr Str Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr TupleLoad Num Num Expr Call AttributeLoad NameLoad attr TupleLoad Num Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num Num Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num Num Num Expr Call AttributeLoad NameLoad attr NameLoad If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Assign NameStore ListComp Str comprehension NameStore NameLoad Expr Call NameLoad NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr ListComp SubscriptLoad NameLoad Index Num comprehension NameStore AttributeLoad NameLoad attr ListComp SubscriptLoad NameLoad Index Num comprehension NameStore AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword Num keyword SubscriptLoad NameLoad Index NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Num Num ListLoad Num Num Str keyword Str If NameLoad body Expr Call AttributeLoad NameLoad attr keyword Str Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore ListComp Call AttributeLoad Call AttributeLoad NameLoad attr attr comprehension NameStore NameLoad Assign NameStore ListLoad For NameStore NameLoad body If CompareEq Call NameLoad NameLoad Num body Continue Assign TupleStore NameStore NameStore NameLoad Expr Call AttributeLoad NameLoad attr TupleLoad Call NameLoad NameLoad Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults Str body Expr Str Assign AttributeStore NameLoad attr Call NameLoad NameLoad Lambda arguments args NameParam NameParam defaults Call NameLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Assign NameStore Num Assign NameStore ListLoad Assign NameStore Num Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr CompareEq SubscriptLoad NameLoad Index Num Num If CompareEq NameLoad Num body Assign NameStore ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr orelse If CompareGt NameLoad NameLoad body Assign NameStore NameLoad orelse While CompareLt NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index NameLoad If CompareEq SubscriptLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Index Num Num body AugAssignAdd NameStore Num AugAssignAdd NameStore Num Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore NameLoad CompareEq SubscriptLoad NameLoad Index Num Num Assign NameStore BinOpSub Call NameLoad NameLoad NameLoad Assign NameStore Num Assign NameStore Num Assign NameStore ListLoad Assign TupleStore NameStore NameStore TupleLoad Num Num Assign TupleStore NameStore NameStore TupleLoad Num Num While CompareLt NameLoad Call NameLoad NameLoad body Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num If CompareNotEq NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad NameLoad If CompareEq SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num Num body AugAssignAdd NameStore Num orelse If CompareEq SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num Num body AugAssignAdd NameStore Num Assign NameStore BinOpDiv NameLoad NameLoad Assign NameStore BinOpDiv NameLoad NameLoad Assign NameStore NameLoad AugAssignAdd NameStore Num Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr keyword Lambda arguments args NameParam defaults TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign AttributeStore NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Num For TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Slice Num Num body Assign NameStore NameLoad Assign NameStore SubscriptLoad NameLoad Index BinOpAdd NameLoad Num AugAssignAdd NameStore BinOpMult BinOpDiv BinOpAdd SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Num BinOpSub SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr CompareEq SubscriptLoad NameLoad Index Num Num Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr CompareEq SubscriptLoad NameLoad Index Num Num Assign NameStore BinOpDiv NameLoad BinOpSub Num NameLoad Assign NameStore BinOpDiv BinOpMult BinOpMult Num NameLoad NameLoad BinOpAdd Num NameLoad Return Call AttributeLoad NameLoad attr BinOpDiv BinOpAdd BinOpAdd BinOpMult NameLoad BinOpSub Num NameLoad BinOpMult BinOpSub NameLoad Num BinOpSub NameLoad BinOpMult NameLoad NameLoad BinOpMult BinOpSub NameLoad Num BinOpSub NameLoad BinOpMult NameLoad NameLoad BinOpMult NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str NameLoad NameLoad body Expr Str Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr ListComp SubscriptLoad NameLoad Index Num comprehension NameStore AttributeLoad NameLoad attr ListComp SubscriptLoad NameLoad Index Num comprehension NameStore AttributeLoad NameLoad attr AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Num Num ListLoad Num Num Str Expr Call AttributeLoad NameLoad attr TupleLoad Num Num Expr Call AttributeLoad NameLoad attr TupleLoad Num Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num Num Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num Num Num Expr Call AttributeLoad NameLoad attr NameLoad If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr CompareGtE SubscriptLoad NameLoad Index Num NameLoad Assign NameStore ListComp NameLoad comprehension NameStore AttributeLoad NameLoad attr CompareLt SubscriptLoad NameLoad Index Num NameLoad Assign TupleStore NameStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Print Str Print Str Print BinOpMod Str TupleLoad NameLoad NameLoad Print BinOpMod Str TupleLoad NameLoad NameLoad Return Dict Str Str Str Str NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign NameStore BinOpDiv BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Call NameLoad Call NameLoad Call AttributeLoad NameLoad attr Assign NameStore BinOpDiv SubscriptLoad NameLoad Index Str Call NameLoad BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Assign NameStore BinOpDiv SubscriptLoad NameLoad Index Str Call NameLoad BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Assign NameStore BinOpDiv BinOpAdd NameLoad NameLoad Num Assign NameStore BinOpDiv SubscriptLoad NameLoad Index Str Call NameLoad BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Assign NameStore BinOpDiv SubscriptLoad NameLoad Index Str Call NameLoad BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Assign NameStore BoolOpOr BinOpDiv BinOpSub BinOpMult SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str BinOpMult SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Call AttributeLoad NameLoad attr BinOpMult BinOpMult BinOpMult BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str BinOpAdd SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Num If NameLoad body Print Str NameLoad Print Str NameLoad Print Str NameLoad Print Str NameLoad Print Str NameLoad Print Str NameLoad Print Str NameLoad Return Dict Str Str Str Str Str Str Str NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore NameLoad CompareEq SubscriptLoad NameLoad Index Num Num Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore NameLoad CompareEq SubscriptLoad NameLoad Index Num Num Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore NameLoad CompareEq SubscriptLoad NameLoad Index Num Num Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore NameLoad CompareEq SubscriptLoad NameLoad Index Num Num Return TupleLoad NameLoad NameLoad NameLoad NameLoad decorator_list decorator_list If CompareEq NameLoad Str body Print Str Print Str Print Str ImportFrom alias Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Num keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str Str keyword Str keyword Str keyword Str Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr If UnaryOpNot AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Expr Call NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr Print BinOpMod Str TupleLoad Call NameLoad Call AttributeLoad NameLoad attr NameLoad Print BinOpMod Str TupleLoad Call NameLoad Call AttributeLoad NameLoad attr NameLoad Print Str For NameStore AttributeLoad NameLoad attr body Print SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num If AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad
N/A N/A 
PyRoc.py

Created by Marcel Caraciolo on 2009-11-16.
Copyright (c) 2009 Federal University of Pernambuco. All rights reserved.

IMPORTANT:
Based on the original code by Eithon Cadag (http://www.eithoncadag.com/files/pyroc.txt)

Python Module for calculating the area under the receive operating characteristic curve, given a dataset.

0.1  - First Release
0.2 - Updated the code by adding new metrics for analysis with the confusion matrix.

 N/A random N/A math N/A N/A N/A pylab N/A N/A N/A N/A error:	can't import pylab module, you must install the module:
 N/A 	matplotlib to plot charts!'
 random_mixture_model N/A N/A pos_mu pos_sigma neg_mu neg_sigma size N/A 0.6 0.1 0.4 0.1 200 N/A N/A pos N/A N/A 1 N/A N/A random gauss pos_mu pos_sigma N/A x N/A xrange N/A size 2 N/A neg N/A N/A 0 N/A N/A random gauss neg_mu neg_sigma N/A x N/A xrange N/A size 2 N/A N/A pos neg N/A plot_multiple_rocs_separate N/A N/A rocList title labels equal_aspect N/A None True N/A N/A  Plot multiples ROC curves as separate at the same painting area.  N/A N/A N/A pylab clf N/A N/A N/A pylab title title N/A N/A ix r N/A enumerate rocList N/A N/A ax N/A N/A pylab subplot 4 4 N/A ix 1 N/A N/A N/A pylab ylim N/A 0 1 N/A N/A N/A pylab xlim N/A 0 1 N/A N/A N/A ax set_yticklabels N/A N/A N/A N/A ax set_xticklabels N/A N/A equal_aspect N/A N/A cax N/A N/A pylab gca N/A N/A N/A cax set_aspect equal N/A N/A labels N/A N/A labels N/A N/A x rocList N/A N/A N/A pylab text 0.2 0.1 N/A labels N/A ix fontsize 8 N/A N/A N/A pylab plot N/A N/A x N/A 0 N/A x N/A r derived_points N/A N/A y N/A 1 N/A y N/A r derived_points r- linewidth 2 N/A N/A N/A pylab show N/A _remove_duplicate_styles N/A N/A rocList N/A N/A N/A  Checks for duplicate linestyles and replaces duplicates with a random one. N/A pref_styles N/A cx- mx- yx- gx- bx- rx- N/A points ov^>+xd N/A colors bgrcmy N/A lines N/A - -. : N/A rand_ls N/A N/A r rocList N/A N/A N/A N/A r linestyle rand_ls N/A N/A N/A N/A rand_ls append N/A r linestyle N/A N/A True N/A N/A N/A N/A len pref_styles 0 N/A N/A pstyle N/A N/A pref_styles pop N/A N/A pstyle rand_ls N/A N/A N/A r linestyle pstyle N/A N/A N/A rand_ls append pstyle N/A N/A N/A ls N/A N/A join N/A N/A N/A N/A random sample colors 1 N/A N/A random sample points 1 N/A N/A random sample lines 1 N/A N/A ls rand_ls N/A N/A N/A r linestyle ls N/A N/A N/A rand_ls append ls N/A N/A plot_multiple_roc N/A N/A rocList title labels include_baseline equal_aspect N/A None False True N/A N/A  Plots multiple ROC curves on the same chart. 
		Parameters:
			rocList: the list of ROCData objects
			title: The tile of the chart
			labels: The labels of each ROC curve
			include_baseline: if it's  True include the random baseline
			equal_aspect: keep equal aspect for all roc curves
	 N/A N/A N/A pylab clf N/A N/A N/A pylab ylim N/A 0 1 N/A N/A N/A pylab xlim N/A 0 1 N/A N/A N/A pylab xticks N/A N/A pylab arange 0 1.1 0.1 N/A N/A N/A pylab yticks N/A N/A pylab arange 0 1.1 0.1 N/A N/A N/A pylab grid True N/A equal_aspect N/A N/A cax N/A N/A pylab gca N/A N/A N/A cax set_aspect equal N/A N/A N/A pylab xlabel 1 - Specificity N/A N/A N/A pylab ylabel Sensitivity N/A N/A N/A pylab title title N/A N/A labels N/A N/A labels N/A N/A x rocList N/A N/A _remove_duplicate_styles rocList N/A N/A ix r N/A enumerate rocList N/A N/A N/A N/A pylab plot N/A N/A x N/A 0 N/A x N/A r derived_points N/A N/A y N/A 1 N/A y N/A r derived_points N/A r linestyle linewidth 1 label N/A labels N/A ix N/A include_baseline N/A N/A N/A N/A pylab plot N/A 0.0 1.0 N/A 0.0 1.0 k- label random N/A labels N/A N/A N/A N/A pylab legend loc lower right N/A N/A N/A pylab show N/A load_decision_function N/A N/A path N/A N/A N/A  Function to load the decision function (DataSet) 
		Parameters:
			path: The dataset file path
		Return:
			model_data: The data modeled
	 N/A fileHandler N/A open path r N/A reader N/A N/A fileHandler readlines N/A reader N/A N/A N/A N/A N/A line strip split N/A line reader N/A model_data N/A N/A line reader N/A N/A N/A N/A len line 0 N/A N/A N/A N/A fClass fValue line N/A N/A N/A model_data append N/A N/A int fClass N/A float fValue N/A N/A N/A fileHandler close N/A model_data N/A ROCData N/A object N/A N/A  Class that generates an ROC Curve for the data.
		Data is in the following format: a list l of tutples t
		where:
			t[0] = 1 for positive class and t[0] = 0 for negative class
			t[1] = score
			t[2] = label
	 __init__ N/A N/A self data linestyle N/A rx- N/A N/A  Constructor takes the data and the line style for plotting the ROC Curve.
			Parameters:
				data: The data a listl of tuples t (l = [t_0,t_1,...t_n]) where:
					  t[0] = 1 for positive class and 0 for negative class
					  t[1] = a score
			 		  t[2] = any label (optional)
				lineStyle: THe matplotlib style string for plots.
				
			Note: The ROCData is still usable w/o matplotlib. The AUC is still available, 
			      but plots cannot be generated.
		 N/A N/A self data N/A sorted data N/A N/A N/A x y N/A N/A cmp N/A y N/A 1 N/A x N/A 1 N/A N/A self linestyle linestyle N/A N/A N/A self auc N/A auc N/A N/A self fpnum N/A 0 N/A N/A  Uses the trapezoidal ruel to calculate the area under the curve. If fpnum is supplied, it will 
			calculate a partial AUC, up to the number of false positives in fpnum (the partial AUC is scaled
			to between 0 and 1).
			It assumes that the positive class is expected to have the higher of the scores (s(+) < s(-))
			Parameters:
				fpnum: The cumulativr FP count (fps)
			Return:
			
		 N/A fps_count 0 N/A relevant_pauc N/A N/A current_index 0 N/A max_n N/A len N/A x N/A x N/A self data N/A N/A x N/A 0 0 N/A N/A fpnum 0 N/A N/A relevant_pauc N/A x N/A x N/A self data N/A N/A N/A fpnum max_n N/A N/A fpnum max_n N/A N/A N/A fps_count fpnum N/A N/A N/A N/A relevant_pauc append N/A N/A self data N/A current_index N/A N/A N/A N/A N/A self data N/A current_index N/A 0 0 N/A N/A fps_count 1 N/A current_index 1 N/A total_n N/A len N/A x N/A x relevant_pauc N/A N/A x N/A 0 0 N/A total_p N/A N/A len relevant_pauc total_n N/A previous_df -1000000.0 N/A current_index 0 N/A points N/A N/A N/A tp_count fp_count N/A 0.0 0.0 N/A N/A tpr fpr N/A 0 0 N/A N/A current_index N/A len relevant_pauc N/A N/A df N/A N/A relevant_pauc N/A current_index N/A 1 N/A N/A previous_df df N/A N/A N/A N/A points append N/A fpr tpr fp_count N/A N/A N/A N/A relevant_pauc N/A current_index N/A 0 0 N/A N/A fp_count 1 N/A N/A N/A N/A N/A relevant_pauc N/A current_index N/A 0 1 N/A N/A tp_count 1 N/A fpr N/A fp_count total_n N/A tpr N/A tp_count total_p N/A previous_df df N/A current_index 1 N/A N/A N/A points append N/A fpr tpr fp_count N/A N/A N/A points sort key N/A N/A N/A i N/A N/A N/A i N/A 0 N/A i N/A 1 N/A N/A self derived_points points N/A N/A N/A self _trapezoidal_rule points N/A _trapezoidal_rule N/A N/A self curve_pts N/A N/A N/A  Method to calculate the area under the ROC curve N/A cum_area 0.0 N/A N/A ix x N/A enumerate N/A curve_pts N/A 0 -1 N/A N/A cur_pt x N/A next_pt N/A curve_pts N/A N/A ix 1 N/A cum_area N/A N/A N/A N/A cur_pt N/A 1 N/A next_pt N/A 1 2.0 N/A N/A next_pt N/A 0 N/A cur_pt N/A 0 N/A cum_area N/A calculateStandardError N/A N/A self fpnum N/A 0 N/A N/A  Returns the standard error associated with the curve.
			Parameters:
				fpnum: The cumulativr FP count (fps)
			Return:
				the standard error.
		 N/A area N/A N/A self auc fpnum N/A Na N/A len N/A x N/A x N/A self data N/A N/A x N/A 0 1 N/A Nn N/A len N/A x N/A x N/A self data N/A N/A x N/A 0 0 N/A Q1 N/A area N/A 2.0 area N/A Q2 N/A N/A N/A 2 area area N/A 1.0 area N/A N/A N/A math sqrt N/A N/A N/A N/A area N/A 1.0 area N/A N/A Na 1.0 N/A Q1 N/A area area N/A N/A Nn 1.0 N/A Q2 N/A area area N/A Na Nn N/A plot N/A N/A self title include_baseline equal_aspect N/A False True N/A N/A  Method that generates a plot of the ROC curve 
			Parameters:
				title: Title of the chart
				include_baseline: Add the baseline plot line if it's True
				equal_aspect: Aspects to be equal for all plot
		 N/A N/A N/A pylab clf N/A N/A N/A pylab plot N/A N/A x N/A 0 N/A x N/A self derived_points N/A N/A y N/A 1 N/A y N/A self derived_points N/A self linestyle N/A include_baseline N/A N/A N/A N/A pylab plot N/A 0.0 1.0 N/A 0.0 1.0 k-. N/A N/A N/A pylab ylim N/A 0 1 N/A N/A N/A pylab xlim N/A 0 1 N/A N/A N/A pylab xticks N/A N/A pylab arange 0 1.1 0.1 N/A N/A N/A pylab yticks N/A N/A pylab arange 0 1.1 0.1 N/A N/A N/A pylab grid True N/A equal_aspect N/A N/A cax N/A N/A pylab gca N/A N/A N/A cax set_aspect equal N/A N/A N/A pylab xlabel 1 - Specificity N/A N/A N/A pylab ylabel Sensitivity N/A N/A N/A pylab title title N/A N/A N/A pylab show N/A confusion_matrix N/A N/A self threshold do_print N/A False N/A N/A  Returns the confusion matrix (in dictionary form) for a fiven threshold
			where all elements > threshold are considered 1 , all else 0.
			Parameters:
				threshold: threshold to check the decision function
				do_print:  if it's True show the confusion matrix in the screen
			Return:
				the dictionary with the TP, FP, FN, TN
		 N/A pos_points N/A x N/A x N/A self data N/A N/A x N/A 1 threshold N/A neg_points N/A x N/A x N/A self data N/A N/A x N/A 1 threshold N/A N/A tp fp fn tn N/A N/A self _calculate_counts pos_points neg_points N/A do_print N/A N/A 	 Actual class N/A 	+(1)	-(0) N/A N/A +(1)	%i	%i	Predicted N/A tp fp N/A N/A -(0)	%i	%i	class N/A fn tn N/A N/A TP FP FN TN tp fp fn tn N/A evaluateMetrics N/A N/A self matrix metric do_print N/A None False N/A N/A  Returns the metrics evaluated from the confusion matrix.
			Parameters:
				matrix: the confusion matrix
				metric: the specific metric of the default value is None (all metrics).
				do_print:  if it's True show the metrics in the screen
			Return:
				the dictionary with the Accuracy, Sensitivity, Specificity,Efficiency,
				                        PositivePredictiveValue, NegativePredictiveValue, PhiCoefficient
		 N/A accuracy N/A N/A N/A matrix N/A TP N/A matrix N/A TN N/A float N/A sum N/A N/A matrix values N/A sensitivity N/A N/A matrix N/A TP N/A float N/A N/A matrix N/A TP N/A matrix N/A FN N/A specificity N/A N/A matrix N/A TN N/A float N/A N/A matrix N/A TN N/A matrix N/A FP N/A efficiency N/A N/A sensitivity specificity 2.0 N/A positivePredictiveValue N/A N/A matrix N/A TP N/A float N/A N/A matrix N/A TP N/A matrix N/A FP N/A NegativePredictiveValue N/A N/A matrix N/A TN N/A float N/A N/A matrix N/A TN N/A matrix N/A FN N/A PhiCoefficient N/A N/A N/A N/A N/A matrix N/A TP N/A matrix N/A TN N/A N/A matrix N/A FP N/A matrix N/A FN N/A N/A math sqrt N/A N/A N/A N/A N/A matrix N/A TP N/A matrix N/A FP N/A N/A matrix N/A TP N/A matrix N/A FN N/A N/A matrix N/A TN N/A matrix N/A FP N/A N/A matrix N/A TN N/A matrix N/A FN 1.0 N/A do_print N/A N/A Sensitivity:  sensitivity N/A Specificity:  specificity N/A Efficiency:  efficiency N/A Accuracy:  accuracy N/A PositivePredictiveValue:  positivePredictiveValue N/A NegativePredictiveValue NegativePredictiveValue N/A PhiCoefficient PhiCoefficient N/A N/A SENS SPEC ACC EFF PPV NPV PHI sensitivity specificity accuracy efficiency positivePredictiveValue NegativePredictiveValue PhiCoefficient N/A _calculate_counts N/A N/A self pos_data neg_data N/A N/A N/A  Calculates the number of false positives, true positives, false negatives and true negatives  N/A tp_count N/A len N/A x N/A x pos_data N/A N/A x N/A 0 1 N/A fp_count N/A len N/A x N/A x pos_data N/A N/A x N/A 0 0 N/A fn_count N/A len N/A x N/A x neg_data N/A N/A x N/A 0 1 N/A tn_count N/A len N/A x N/A x neg_data N/A N/A x N/A 0 0 N/A N/A tp_count fp_count fn_count tn_count N/A N/A N/A N/A __name__ __main__ N/A N/A PyRoC - ROC Curve Generator N/A By Marcel Pinheiro Caraciolo (@marcelcaraciolo) N/A http://aimotion.bogspot.com
 optparse OptionParser N/A parser N/A OptionParser N/A N/A N/A parser add_option -f --file dest origFile help Path to a file with the class and decision function. The first column of each row is the class, and the second the decision score. N/A N/A N/A parser add_option -n --max fp dest fp_n default 0 help Maximum false positives to calculate up to (for partial AUC). N/A N/A N/A parser add_option -p --plot action store_true dest plotFlag default False help Plot the ROC curve (matplotlib required) N/A N/A N/A parser add_option -t --title dest ptitle default help Title of plot. N/A N/A options args N/A N/A parser parse_args N/A N/A N/A options origFile N/A N/A N/A N/A parser print_help N/A N/A exit N/A df_data N/A load_decision_function N/A options origFile N/A roc N/A ROCData df_data N/A roc_n N/A int N/A options fp_n N/A N/A ROC AUC: %s N/A N/A str N/A N/A roc auc roc_n N/A N/A Standard Error:  %s N/A N/A str N/A N/A roc calculateStandardError roc_n N/A N/A pt N/A roc derived_points N/A N/A N/A pt N/A 0 N/A pt N/A 1 N/A N/A options plotFlag N/A N/A N/A N/A roc plot N/A options ptitle True True