def trainClassifer(self,labels,vectors,verbose=False,ilog=None):
        '''
        Do not call this function instead call train.
        '''
        
        if len(self.lams) > 1 or len(self.kernels) > 1:
            # optimize kernel and lambda using a grid search
            
            if self.training_size <= 1.0:
                self.training_size = int(self.training_size*len(labels))
            else:
                self.training_size = int(self.training_size)
            
            if self.validation_size == None:
                self.validation_size = len(labels) - int(self.training_size)
            else:
                self.validation_size = int(self.validation_size)
            
            train_labels   = []
            train_vectors  = []
            verify_labels  = []
            verify_vectors = []
            
            order = list(range(len(labels)))
            self.rng.shuffle(order)
            for i in order[:self.training_size]:
                train_labels.append(labels[i])
                train_vectors.append(vectors[i])
            for i in order[self.training_size:self.training_size+self.validation_size]:
                verify_labels.append(labels[i])
                verify_vectors.append(vectors[i])
            
            best_mse = None
            best_lam = None
            best_kernel = None

            self.training_size = len(train_labels)
            
            c = len(train_labels)
            r = len(train_vectors[0])
            
            self.c = c
            self.r = r
            y = np.array(train_labels,'d')
            
            X = np.zeros((r,c),'d')
            for i in range(len(train_vectors)):
                X[:,i] = train_vectors[i]
    
            self.X = X
            
            for kernel in self.kernels:
                self.kernel = kernel
                
                kernel_matrix = np.zeros((c,c),'d')
                for i in range(c):
                    kernel_matrix[i,:] = self.kernel(X,X[:,i:i+1])

                
                for lam in self.lams:
                    self.lam = lam

                    self.w = np.dot(y,np.linalg.inv(kernel_matrix + self.lam*np.eye(c)))
                    
                    n = len(verify_labels)
                    mse = 0.0
                    for i in range(n):
                        e = verify_labels[i] - self.predictValue(verify_vectors[i])
                        mse += e*e
                    mse = mse/n
                    
                    self.training_info.append([lam,kernel,mse])
                    
                    if verbose: print "KRR Trianing: %s %10.5f %s %10.5f %s"%(kernel_matrix.shape,lam,kernel,mse,best_mse)
                    #   %s   %10.5f   %10.5f"%(lam,kernel,mse,best_mse)
                    if best_mse == None or best_mse > mse:
                        best_mse    = mse
                        best_lam    = lam
                        best_kernel = kernel
            
            self.mse    = best_mse
            self.lam    = best_lam
            self.kernel = best_kernel
            
        else:
            self.lam    = self.lams[0]
            self.kernel = self.kernels[0]
        
        self.trainRidgeRegression(labels,vectors,verbose=verbose)
dataset/ETHPy150Open bolme/pyvision/src/pyvision/vector/RidgeRegression.py/KernelRidgeRegression.trainClassifer/original