def run_real(self): """Runs the main application""" # Get the type of the curve to be plotted try: self.curve_class = CurveFactory.find_class_by_name(self.options.curve_type) except ValueError: self.parser.error("Unsupported curve type: %s" % self.options.curve_type) self.process_input_files() self.run_tests()
def run_real(self): """Runs the main application""" # If no curve type was given, assume a ROC curve if not self.options.curve_types: self.options.curve_types = ["roc"] # Get the types of the curves to be plotted curve_classes = [] for name in self.options.curve_types: try: curve_classes.append(CurveFactory.find_class_by_name(name)) except ValueError: self.parser.error("Unknown curve type: %s" % name) self.process_input_files() for curve_class in curve_classes: self.print_scores_for_curve(curve_class)
def run_real(self): """Runs the main application""" # If no curve type was given, assume a ROC curve if not self.options.curve_types: self.options.curve_types = ["roc"] # Get the types of the curves to be plotted curve_classes = [] for name in self.options.curve_types: try: curve_classes.append(CurveFactory.find_class_by_name(name)) except ValueError: self.parser.error("Unknown curve type: %s" % name) self.process_input_files() for curve_class in curve_classes: self.print_scores_for_curve(curve_class)
def run_real(self): """Runs the main application""" import matplotlib # Do we need headless mode for matplotlib? if self.options.output: matplotlib.use("agg") # If no curve type was given, assume a ROC curve if not self.options.curve_types: self.options.curve_types = ["roc"] # Set up the font size if self.options.font_size is not None: for param in ['font.size', 'legend.fontsize']: matplotlib.rcParams[param] = self.options.font_size # Get the types of the curves to be plotted curve_classes = [] for name in self.options.curve_types: try: curve_classes.append(CurveFactory.find_class_by_name(name)) except ValueError: self.parser.error("Unknown curve type: %s" % name) # Do we have multiple curve types? If so, we need PDF output pp = None if len(curve_classes) > 1: if not self.options.output or \ not self.options.output.endswith(".pdf"): self.parser.error("multiple curves can only be plotted to PDF") try: from matplotlib.backends.backend_pdf import PdfPages except ImportError: self.parser.error("Matplotlib is too old and does not have " "multi-page PDF support yet. Please upgrade it to " "Matplotlib 0.99 or later") pp = PdfPages(self.options.output) def figure_saver(figure): pp.savefig(figure, bbox_inches="tight") elif self.options.output: # Figure with a single plot will be created def figure_saver(figure): self.log.info("Saving plot to %s..." % self.options.output) figure.savefig(self.options.output, bbox_inches="tight") else: # Figure will be shown on screen def figure_saver(figure): import matplotlib.pyplot as plt plt.show() self.process_input_files() self.log.info("Plotting results...") for curve_class in curve_classes: fig = self.get_figure_for_curves(curve_class) figure_saver(fig) # For multi-page output, we have to close it explicitly if pp is not None: pp.close()
def run_real(self): """Runs the main application""" import matplotlib # Do we need headless mode for matplotlib? if self.options.output: matplotlib.use("agg") # If no curve type was given, assume a ROC curve if not self.options.curve_types: self.options.curve_types = ["roc"] # Set up the font size if self.options.font_size is not None: for param in ['font.size', 'legend.fontsize']: matplotlib.rcParams[param] = self.options.font_size # Get the types of the curves to be plotted curve_classes = [] for name in self.options.curve_types: try: curve_classes.append(CurveFactory.find_class_by_name(name)) except ValueError: self.parser.error("Unknown curve type: %s" % name) # Do we have multiple curve types? If so, we need PDF output pp = None if len(curve_classes) > 1: if not self.options.output or \ not self.options.output.endswith(".pdf"): self.parser.error("multiple curves can only be plotted to PDF") try: from matplotlib.backends.backend_pdf import PdfPages except ImportError: self.parser.error( "Matplotlib is too old and does not have " "multi-page PDF support yet. Please upgrade it to " "Matplotlib 0.99 or later") pp = PdfPages(self.options.output) def figure_saver(figure): pp.savefig(figure, bbox_inches="tight") elif self.options.output: # Figure with a single plot will be created def figure_saver(figure): self.log.info("Saving plot to %s..." % self.options.output) figure.savefig(self.options.output, bbox_inches="tight") else: # Figure will be shown on screen def figure_saver(figure): import matplotlib.pyplot as plt plt.show() self.process_input_files() self.log.info("Plotting results...") for curve_class in curve_classes: fig = self.get_figure_for_curves(curve_class) figure_saver(fig) # For multi-page output, we have to close it explicitly if pp is not None: pp.close()