예제 #1
0
    def calculate_status(self):
        """ Status calculation using expected output and  classified class
            with its confidence.
        """
        conf_cl = self.confidence
        confidence = self.confidence_level(conf_cl)

        cat_cl = self.label.lower()
        if cat_cl == LABEL_BROKEN.lower():
            return self.BTM_NO_STATUS

        expect = self.expected_output.lower()

        if cat_cl == expect and confidence == self.CONF_HIGH:
            return self.BTM_KNOWN

        elif cat_cl == expect and confidence == self.CONF_MEDIUM:
            return self.BTM_HUMAN

        elif cat_cl != expect and confidence == self.CONF_MEDIUM:
            return self.BTM_HUMAN

        elif cat_cl != expect and confidence == self.CONF_HIGH:
            return self.BTM_HUMAN

        # Should not happened!
        return self.BTM_NO_STATUS
예제 #2
0
    def recalculate_human(self, cat_h):
        """ Recalculates btm sample status after voting of unsure sample.
        """
        if self.frozen:
            log.warning(
                "Tried to update BTMSample %s which is frozen(paid)." % self.id
            )
            return

        conf_cl = self.confidence
        confidence = self.confidence_level(conf_cl)

        cat_h = cat_h.lower()
        cat_cl = self.label.lower()

        if cat_cl == LABEL_BROKEN.lower() or cat_h == LABEL_BROKEN.lower():
            return self.BTM_NO_STATUS

        expect = self.expected_output.lower()

        if cat_cl == expect and confidence == self.CONF_HIGH:
            self.btm_status = self.BTM_KNOWN

        elif cat_cl == expect and confidence == self.CONF_MEDIUM:
            if cat_h == expect:
                self.btm_status = self.BTM_KNOWN_UNSURE
            else:
                self.btm_status = self.BTM_X_CORRECTED

        elif cat_cl != expect and confidence == self.CONF_HIGH:
            if cat_h == expect:
                self.btm_status = self.BTM_HOLE
            else:
                self.btm_status = self.BTM_NOT_NONX

        elif cat_cl != expect and confidence == self.CONF_MEDIUM:
            if cat_h == expect:
                self.btm_status = self.BTM_NOTX_CORRECTED
            else:
                self.btm_status = self.BTM_KNOWN_UNSURE

        self.update_points(self.btm_status)
        self.human_label = make_label(cat_h)
        self.save()
예제 #3
0
    def confidence(self):
        if self.label.lower() == LABEL_BROKEN.lower():
            log.warning(
                "BTM sample %s confidence 0.0 due to broken label." % self.id
            )
            return 0

        try:
            return self.fixed_probability[self.label]
        except KeyError:
            return self.fixed_probability[self.label.capitalize()]