Changeset 10:dc1520d0d39f in orange-reliability


Ignore:
Timestamp:
07/09/12 15:18:03 (22 months ago)
Author:
Matija Polajnar <matija.polajnar@…>
Branch:
default
Message:

Add reference method for classification.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _reliability/__init__.py

    r9 r10  
    3737MAHAL_TO_CENTER_ABSOLUTE = 13 
    3838DENS_ABSOLUTE = 14 
     39ERR_ABSOLUTE = 15 
    3940 
    4041# Type of estimator constant 
     
    4748               6: "LCV absolute", 7: "BVCK_absolute", 8: "Mahalanobis absolute", 
    4849               9: "BLENDING absolute", 10: "ICV", 11: "RF Variance", 12: "RF Std", 
    49                13: "Mahalanobis to center", 14: "Density based"} 
     50               13: "Mahalanobis to center", 14: "Density based", 15: "Reference expected error"} 
    5051 
    5152select_with_repeat = Orange.core.MakeRandomIndicesMultiple() 
     
    378379                Estimate(SAbias, SIGNED, SABIAS_SIGNED), 
    379380                Estimate(abs(SAbias), ABSOLUTE, SABIAS_ABSOLUTE)] 
     381 
     382 
     383 
     384class ReferenceExpectedError: 
     385 
     386    def __init__(self, name="reference"): 
     387        self.name = name 
     388 
     389    def __call__(self, instances, learner): 
     390        classifier = learner(instances) 
     391        return ReferenceExpectedErrorClassifier(classifier) 
     392 
     393     
     394class ReferenceExpectedErrorClassifier: 
     395 
     396    def __init__(self, classifier): 
     397        self.classifier = classifier 
     398 
     399    def __call__(self, instance, *args): 
     400        y_hat = max(self.classifier(instance, Orange.classification.Classifier.GetProbabilities)) 
     401        return [Estimate(2 * y_hat * (1 - y_hat), ABSOLUTE, ERR_ABSOLUTE)] 
     402 
     403     
    380404 
    381405class BaggingVariance: 
Note: See TracChangeset for help on using the changeset viewer.