Beispiel #1
0
    def __init__(self,
                 svm_type=TYPE_SVC,
                 kernel=KERNEL_RBF,
                 svr_epsilon=0.1,
                 nu=0.5,
                 random_seed=None,
                 validation_size=0.33,
                 **kwargs):
        '''
        Create an svm.
        
        Make sure you choose "classifacition" or "regression".  Other parameters control
        features of the SVM.
        
        also passes keyword args to VectorClassifier
        '''
        #TODO: Document constructor
        #TODO: Add an option to specify SVM parameters directly and disable automatic tuning.
        self.svm = None
        self.svm_type = svm_type
        self.kernel = kernel
        self.epsilon = svr_epsilon
        self.nu = nu
        self.random_seed = random_seed
        self.validation_size = validation_size

        if svm_type in (TYPE_C_SVC, TYPE_NU_SVC):
            VectorClassifier.__init__(self, TYPE_MULTICLASS, **kwargs)
        else:
            VectorClassifier.__init__(self, TYPE_REGRESSION, **kwargs)
Beispiel #2
0
    def __init__(self,
                 training_size=0.67, # The fraction of the data to use for training
                 validation_size=None, # The fraction of the data to use for training
                 kernels= [RBF(gamma=2**i) for i in range(-15,4)], 
                 lams   = [2.0**i for i in range(-8,9)],
                 random_seed = None,
                 **kwargs):

        if isinstance(lams,list):
            self.lams = lams
        else:
            self.lams = [lams]
            
        if isinstance(kernels,list):
            self.kernels = kernels
        else:
            self.kernels = [kernels]
            
        self.training_size = training_size
        self.validation_size = validation_size
        
        # set durring training
        self.mse           = None
        self.lam           = None
        self.kernel        = None
        self.training_info = []
        
        self.rng = random.Random(random_seed)
        
        VectorClassifier.__init__(self,TYPE_REGRESSION,**kwargs)
Beispiel #3
0
 def __init__(self, order=2, **kwargs):
     #FIXME: DOcument this code
     '''
     This class fits a polynomial to a function of 2 variables.
     '''
     self.order = order
     self.x = None
     VectorClassifier.__init__(self, TYPE_REGRESSION, **kwargs)
Beispiel #4
0
 def __init__(self,order=2,**kwargs):
     #FIXME: DOcument this code
     '''
     This class fits a polynomial to a function of 2 variables.
     '''
     self.order = order
     self.x = None
     VectorClassifier.__init__(self,TYPE_REGRESSION,**kwargs)
Beispiel #5
0
 def __init__(self, svm_type=TYPE_SVC, kernel=KERNEL_RBF, svr_epsilon=0.1, nu = 0.5, random_seed=None, validation_size=0.33,**kwargs):
     '''
     Create an svm.
     
     Make sure you choose "classifacition" or "regression".  Other parameters control
     features of the SVM.
     
     also passes keyword args to VectorClassifier
     '''
     #TODO: Document constructor
     #TODO: Add an option to specify SVM parameters directly and disable automatic tuning.
     self.svm = None
     self.svm_type = svm_type
     self.kernel = kernel
     self.epsilon=svr_epsilon
     self.nu = nu
     self.random_seed = random_seed
     self.validation_size = validation_size
     
     if svm_type in (TYPE_C_SVC,TYPE_NU_SVC): 
         VectorClassifier.__init__(self,TYPE_MULTICLASS,**kwargs)
     else:
         VectorClassifier.__init__(self,TYPE_REGRESSION,**kwargs)
Beispiel #6
0
 def __init__(self,lam=0.1,**kwargs):
     self.lam = lam
     
     VectorClassifier.__init__(self,TYPE_REGRESSION,**kwargs)