Changeset 7322:ab7805f3bda0 in orange


Ignore:
Timestamp:
02/03/11 13:30:32 (3 years ago)
Author:
tomazc <tomaz.curk@…>
Branch:
default
Convert:
e3f810f78295af130a7700a7c31981e37f2cd011
Message:

Documentatio and code refactoring at Bohinj retreat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/orngImpute.py

    r6538 r7322  
    1 import orange 
    2  
    3 class ImputeLearner(orange.Learner): 
    4     def __new__(cls, examples = None, weightID = 0, **keyw): 
    5         self = orange.Learner.__new__(cls, **keyw) 
    6         self.dontImputeClassifier = False 
    7         self.__dict__.update(keyw) 
    8         if examples: 
    9             return self.__call__(examples, weightID) 
    10         else: 
    11             return self 
    12          
    13     def __call__(self, data, weight=0): 
    14         trained_imputer = self.imputerConstructor(data, weight) 
    15         imputed_data = trained_imputer(data, weight) 
    16         baseClassifier = self.baseLearner(imputed_data, weight) 
    17         if self.dontImputeClassifier: 
    18             return baseClassifier 
    19         else: 
    20             return ImputeClassifier(baseClassifier, trained_imputer) 
    21  
    22 class ImputeClassifier(orange.Classifier): 
    23     def __init__(self, baseClassifier, imputer, **argkw): 
    24         self.baseClassifier = baseClassifier 
    25         self.imputer = imputer 
    26         self.__dict__.update(argkw) 
    27  
    28     def __call__(self, ex, what=orange.GetValue): 
    29         return self.baseClassifier(self.imputer(ex), what) 
     1from Orange.feature.impute import Learner as ImputeLearner 
     2from Orange.feature.impute import Classifier as ImputeClassifier 
Note: See TracChangeset for help on using the changeset viewer.