Пример #1
0
 def update(self, name, value):
     if name in [ 'rocfname', 'typeinfo', 'bancascores']:
         if self.rocfname:
             #TODO manage erroneous files
             db = np.loadtxt(self.rocfname)
             self.rocscores = ROCScores(db, self.typeinfo.lower())
         else:
              bancadb = banca.Banca()
              db = bancadb.get_data(self.bancascores[:2], self.bancascores[3:])
              print self.bancascores[:2]
              print self.bancascores[3:]
              self.rocscores = ROCScores(db, 'score')
Пример #2
0
class RocManager(HasTraits):

    # Reference to the ROC curve
    rocfname = File(label='Score file',
                    desc='The file containing the ROC curve scores')
    bancascores = banca_choose

    # Type of information
    typeinfo = type_score_type

    # Number of bootstrapq
    nbbootstrap = nb_bootstrap_type

    # Alpha
    alpha = alpha_type

    # Container of the ROC scores
    rocscores = Instance(ROCScores)

    # Use bootstrap
    usebootstrap = Bool(True,
                        label= 'Use bootstrap',
                        desc='Check if you want to use bootstrap')



    @on_trait_change('rocfname', 'typeinfo', 'nbbootstrap', 'alpha',
            'usebootstrap', 'bancascores')
    def update(self, name, value):
        if name in [ 'rocfname', 'typeinfo', 'bancascores']:
            if self.rocfname:
                #TODO manage erroneous files
                db = np.loadtxt(self.rocfname)
                self.rocscores = ROCScores(db, self.typeinfo.lower())
            else:
                 bancadb = banca.Banca()
                 db = bancadb.get_data(self.bancascores[:2], self.bancascores[3:])
                 print self.bancascores[:2]
                 print self.bancascores[3:]
                 self.rocscores = ROCScores(db, 'score')


    def compute(self):
        """Compute all the necessary things for the ROC curve."""

        if self.usebootstrap:
            # We ask to use bootstrap
            self.rocscores.get_confidence_interval(\
                alpha=self.alpha,
                repet=self.nbbootstrap
                )
        else:
            roccurve = self.rocscores.get_roc()
            plt.figure()
            roccurve.plot()

            roccurve.get_polar_representation().plot()

            plt.figure()
            roccurve.plot_det()

            plt.figure()
            self.rocscores.display_distributions()

            plt.figure()
            roccurve.plot_FMR_FNMR_versus_threshold()
            plt.show()