コード例 #1
0
ファイル: analysis.py プロジェクト: ferrouswheel/mdig
 def do_me(self, mdig_model):
     # TODO move this to roc module
     if "linux" not in sys.platform:
         print "ROC analysis not supported on platforms other than Linux"
         sys.exit(1)
     from mdig.roc import ROCAnalysis
     self.ROC = ROCAnalysis(self.model_names, self.options)
     self.ROC.run()
コード例 #2
0
ファイル: analysis.py プロジェクト: dgpreatoni/mdig
 def do_me(self,mdig_model):
     # TODO move this to roc module
     if "linux" not in sys.platform:
        print "ROC analysis not supported on platforms other than Linux"
        sys.exit(1)
     from mdig.roc import ROCAnalysis
     self.ROC = ROCAnalysis(self.model_names,self.options)
     self.ROC.run()
コード例 #3
0
ファイル: analysis.py プロジェクト: ferrouswheel/mdig
class ROCAction(Action):
    description = "Create Receiver Operating Characteristic curves for " + \
        "occupancy envelopes and calculate AUC."

    def __init__(self):
        super(ROCAction, self).__init__()
        self.parser = OptionParser(
            version=mdig.version_string,
            description=self.description,
            usage="%prog roc [options] <model_name1> <model_name2> ...")
        # Can theoretically run on any number of models
        self.model_limit = None
        self.preload = False
        self.add_options()

    def add_options(self):
        super(ROCAction, self).add_options()
        self.parser.add_option("-o",
                               "--overwrite",
                               help="Overwrite existing files",
                               action="store_true",
                               dest="overwrite_flag")
        self.parser.add_option(
            "-b",
            "--bootstraps",
            help="Number of resamplings to use for creating statistics",
            action="store",
            dest="bootstraps")
        self.parser.add_option("-V",
                               "--vuc",
                               help="Calculate Volume Under the Curve",
                               action="store_true",
                               dest="calc_vuc")
        self.parser.add_option("-a",
                               "--auc",
                               help="Calculate Area Under the Curve",
                               action="store_true",
                               dest="calc_auc")
        self.parser.add_option("--graph-auc",
                               help="Graph the change in AUC over time",
                               action="store_true",
                               dest="graph_auc")
        self.parser.add_option(
            "--graph-roc",
            help=
            "Graph yearly ROC curves (creates one for each year and replicate)",
            action="store_true",
            dest="graph_roc")
        self.parser.add_option("-x",
                               "--start",
                               help="Start time to calculate ROC/AUC for",
                               action="store",
                               type="int",
                               dest="start_time")
        self.parser.add_option("-y",
                               "--end",
                               help="End time to calculate ROC/AUC for",
                               action="store",
                               type="int",
                               dest="end_time")
        self.parser.add_option(
            "-s",
            "--sites",
            help="The vector that will contain the sites to compare " +
            "performance with (required).",
            action="store",
            dest="sites_vector",
            type="string")
        self.parser.add_option(
            "-m",
            "--mask",
            help="The raster map used as the limit for where random " +
            "absences can go and used for the total area to compare to.",
            action="store",
            dest="area_mask",
            type="string")
        self.parser.add_option(
            "-l",
            "--lifestage",
            help="Lifestage to analyse (lifestage name or default='all')",
            action="store",
            dest="lifestage",
            type="string")
        self.parser.add_option(
            "-d",
            "--dir",
            help="Base directory to save output in (don't use repository)",
            action="store",
            dest="output_dir",
            type="string")
        self.parser.add_option(
            "-t",
            "--tags",
            help=
            "List of comma separated tags for labelling each model within graph legends",
            action="store",
            dest="model_tags",
            type="string")

    def act_on_options(self, options):
        super(ROCAction, self).act_on_options(self, options)
        config.get_config().overwrite_flag = self.options.overwrite_flag
        if self.options.lifestage is None:
            self.options.lifestage = "all"
        if self.options.sites_vector is None:
            self.log.error("No sites vector provided.")
            sys.exit(mdig.mdig_exit_codes["cmdline_error"])
        if self.options.area_mask is None:
            self.log.error("No area mask specified.")
            sys.exit(mdig.mdig_exit_codes["cmdline_error"])
        if self.options.output_dir is not None:
            if not os.path.isdir(options.output_dir):
                self.log.info(
                    "Directory %s doesn't exist, attemping to" + " create\n",
                    options.output_dir)
                utils.make_path(options.output_dir)
        else:
            self.options.output_dir = "."
        if self.options.model_tags is not None:
            tags = self.options.model_tags.split(",")
            if len(tags) != len(self.model_names):
                self.log.error("Number of tags given not the same as number "+\
                        " of models.")
                sys.exit(mdig.mdig_exit_codes["cmdline_error"])
            self.options.model_tags = tags

    def do_me(self, mdig_model):
        # TODO move this to roc module
        if "linux" not in sys.platform:
            print "ROC analysis not supported on platforms other than Linux"
            sys.exit(1)
        from mdig.roc import ROCAnalysis
        self.ROC = ROCAnalysis(self.model_names, self.options)
        self.ROC.run()
コード例 #4
0
ファイル: analysis.py プロジェクト: dgpreatoni/mdig
class ROCAction(Action):
    description = "Create Receiver Operating Characteristic curves for " + \
        "occupancy envelopes and calculate AUC."

    def __init__(self):
        super(ROCAction, self).__init__()
        self.parser = OptionParser(version=mdig.version_string,
                description = self.description,
                usage = "%prog roc [options] <model_name1> <model_name2> ...")
        # Can theoretically run on any number of models
        self.model_limit = None
        self.preload = False
        self.add_options()
        
    def add_options(self):
        super(ROCAction, self).add_options()
        self.parser.add_option("-o","--overwrite",
                help="Overwrite existing files",
                action="store_true",
                dest="overwrite_flag")
        self.parser.add_option("-b","--bootstraps",
                help="Number of resamplings to use for creating statistics",
                action="store",
                dest="bootstraps")
        self.parser.add_option("-V","--vuc",
                help="Calculate Volume Under the Curve",
                action="store_true",
                dest="calc_vuc")
        self.parser.add_option("-a","--auc",
                help="Calculate Area Under the Curve",
                action="store_true",
                dest="calc_auc")
        self.parser.add_option("--graph-auc",
                help="Graph the change in AUC over time",
                action="store_true",
                dest="graph_auc")
        self.parser.add_option("--graph-roc",
                help="Graph yearly ROC curves (creates one for each year and replicate)",
                action="store_true",
                dest="graph_roc")
        self.parser.add_option("-x","--start",
                help="Start time to calculate ROC/AUC for",
                action="store",
                type="int",
                dest="start_time")
        self.parser.add_option("-y","--end",
                help="End time to calculate ROC/AUC for",
                action="store",
                type="int",
                dest="end_time")
        self.parser.add_option("-s","--sites",
                help="The vector that will contain the sites to compare " +
                    "performance with (required).",
                action="store",
                dest="sites_vector",
                type="string")
        self.parser.add_option("-m","--mask",
                help="The raster map used as the limit for where random " +
                "absences can go and used for the total area to compare to.",
                action="store",
                dest="area_mask",
                type="string")
        self.parser.add_option("-l","--lifestage",
                help="Lifestage to analyse (lifestage name or default='all')",
                action="store",
                dest="lifestage",
                type="string")
        self.parser.add_option("-d","--dir",
                help="Base directory to save output in (don't use repository)",
                action="store",
                dest="output_dir",
                type="string")
        self.parser.add_option("-t","--tags",
                help="List of comma separated tags for labelling each model within graph legends",
                action="store",
                dest="model_tags",
                type="string")

    def act_on_options(self,options):
        super(ROCAction, self).act_on_options(self, options)
        config.get_config().overwrite_flag = self.options.overwrite_flag
        if self.options.lifestage is None:
            self.options.lifestage = "all"
        if self.options.sites_vector is None:
            self.log.error("No sites vector provided.")
            sys.exit(mdig.mdig_exit_codes["cmdline_error"])
        if self.options.area_mask is None:
            self.log.error("No area mask specified.")
            sys.exit(mdig.mdig_exit_codes["cmdline_error"])
        if self.options.output_dir is not None:
            if not os.path.isdir(options.output_dir):
                self.log.info("Directory %s doesn't exist, attemping to" +
                        " create\n",options.output_dir)
                utils.make_path(options.output_dir)
        else:
            self.options.output_dir = "."
        if self.options.model_tags is not None:
            tags = self.options.model_tags.split(",")
            if len(tags) != len(self.model_names):
                self.log.error("Number of tags given not the same as number "+\
                        " of models.")
                sys.exit(mdig.mdig_exit_codes["cmdline_error"])
            self.options.model_tags = tags
    
    def do_me(self,mdig_model):
        # TODO move this to roc module
        if "linux" not in sys.platform:
           print "ROC analysis not supported on platforms other than Linux"
           sys.exit(1)
        from mdig.roc import ROCAnalysis
        self.ROC = ROCAnalysis(self.model_names,self.options)
        self.ROC.run()