Changeset 3715:d86445c3bca4 in orange


Ignore:
Timestamp:
05/31/07 10:50:51 (7 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
6385c5a0bd1721fc85a02d6b7b6cb538942a3a75
Message:

no message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/orngSVM.py

    r3677 r3715  
    5454    def __call__(self, examples, weight=0): 
    5555        if self.svm_type in [0,1] and examples.domain.classVar.varType!=orange.VarTypes.Discrete: 
    56             raise AttributeError, "Cannot learn a discrete classifier from non descrete class data. Use EPSILON_SVR or NU_SVR for regression" 
     56            self.svm_type+=3 
     57            #raise AttributeError, "Cannot learn a discrete classifier from non descrete class data. Use EPSILON_SVR or NU_SVR for regression" 
    5758        if self.svm_type in [3,4] and examples.domain.classVar.varType==orange.VarTypes.Discrete: 
    58             raise AttributeError, "Cannot do regression on descrete class data. Use C_SVC or NU_SVC for classification" 
     59            self.svm_type-=3 
     60            #raise AttributeError, "Cannot do regression on descrete class data. Use C_SVC or NU_SVC for classification" 
    5961        if self.kernel_type==4 and not self.kernelFunc: 
    6062            raise AttributeError, "Custom kernel function not supplied" 
     
    174176         
    175177class SVMClassifierClassEasyWrapper: 
    176     def __init__(self, classifier, domain=None): 
     178    def __init__(self, classifier, domain=None, transformer=None): 
    177179        self.classifier=classifier 
    178180        self.domain=domain 
    179     def __call__(self,example, getBoth=orange.GetBoth): 
     181    def __call__(self,example, getBoth=orange.GetValue): 
    180182        example=orange.Example(self.domain, example) 
    181183        return self.classifier(example, getBoth) 
    182184    def __getattr__(self, name): 
    183         return getattr(self.classifier,name) 
     185        if name in ["supportVectors", "nSV", "coef", "rho", "examples", "kernelFunc"]: 
     186            return getattr(self.__dict__["classifier"], name) 
     187        else: 
     188            return object.__getattr__(self, name) 
    184189 
    185190def getLinearSVMWeights(classifier): 
    186     """returns list of weights of linear class vs. class classifiers for the linear multiclass svm classifier. The list is in the order of 1vs2, 1vs3 ... 1vsN, 2vs3 ...""" 
     191    """returns list of weights for linear class vs. class classifiers for the linear multiclass svm classifier. The list is in the order of 1vs2, 1vs3 ... 1vsN, 2vs3 ...""" 
    187192    def updateWeights(w, key, val, mul): 
    188193        if key in w: 
Note: See TracChangeset for help on using the changeset viewer.