Exemple #1
0
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("softmax_entropy"),
                    SoftmaxEntropy))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("SoftmaxEntropy"),
                    SoftmaxEntropy))
Exemple #2
0
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("predictive_entropy"), PredictiveEntropy)
     )
     self.assertTrue(
         isinstance(QuantifierRegistry.find("pred_entropy"), PredictiveEntropy)
     )
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("mutual_information"),
                    MutualInformation))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("mutu_info"),
                    MutualInformation))
Exemple #4
0
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("variation_ratio"),
                    VariationRatio))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("var_ratio"), VariationRatio))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("VR"), VariationRatio))
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("standard_deviation"),
                    StandardDeviation))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("std"), StandardDeviation))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("stddev"), StandardDeviation))
Exemple #6
0
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("PCS"),
                    PredictionConfidenceScore))
     self.assertTrue(
         isinstance(
             QuantifierRegistry.find("prediction_confidence_score"),
             PredictionConfidenceScore,
         ))
Exemple #7
0
    def _quantifiers_as_list(quantifier):
        is_single_quantifier = False
        if isinstance(quantifier, list):
            quantifiers = quantifier
        else:
            quantifiers = [quantifier]
            is_single_quantifier = True

        quantifier_objects = []
        for quantifier in quantifiers:
            if isinstance(quantifier, str):
                quantifier_objects.append(QuantifierRegistry.find(quantifier))
            elif isinstance(quantifier, Quantifier):
                quantifier_objects.append(quantifier)
            else:
                raise TypeError(
                    "The passed quantifier is neither a quantifier instance nor a quantifier alias (str)."
                    f"Type of the passed object {str(type(quantifier))}")

        point_prediction_quantifiers = [
            q for q in quantifier_objects if q.takes_samples() is False
        ]
        samples_based_quantifiers = [
            q for q in quantifier_objects if q.takes_samples() is True
        ]
        return (
            quantifier_objects,
            point_prediction_quantifiers,
            samples_based_quantifiers,
            is_single_quantifier,
        )
Exemple #8
0
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("softmax"), MaxSoftmax))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("max_softmax"), MaxSoftmax))
Exemple #9
0
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("mean_softmax"), MeanSoftmax))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("ensembling"), MeanSoftmax))
 def test_string_representation(self):
     self.assertTrue(
         isinstance(QuantifierRegistry.find("DeepGini"), DeepGini))
     self.assertTrue(
         isinstance(QuantifierRegistry.find("deep_gini"), DeepGini))
Exemple #11
0
 def test_error_if_invalid_quantifier_alias(self):
     with self.assertRaises(ValueError):
         QuantifierRegistry.find("nonexistent_q_hi1ö2rn1ld")
Exemple #12
0
 def test_error_if_alias_already_exists(self):
     with self.assertRaises(ValueError):
         QuantifierRegistry.register(VariationRatio())