예제 #1
0
    def loadResources(self):
        """
        Loads the resources from the previously set resource pool.
        
        @raise Exception: when some of the resources required by the learner is not available in the ResourcePool object.
        """
        AbstractIterativeLearner.loadResources(self)

        Y = self.resource_pool['train_labels']
        self.Y = Y
        #Number of training examples
        self.size = Y.shape[0]
        if not Y.shape[1] == 1:
            raise Exception(
                'GreedyRLS currently supports only one output at a time. The output matrix is now of shape '
                + str(Y.shape) + '.')

        X = self.resource_pool['train_features']
        self.setDataMatrix(X.T)
        if self.resource_pool.has_key('bias'):
            self.bias = float(self.resource_pool['bias'])
        else:
            self.bias = 0.
        if self.resource_pool.has_key('measure'):
            self.measure = self.resource_pool['measure']
        else:
            self.measure = None
        qids = self.resource_pool['train_qids']
        if not self.resource_pool.has_key('cross-validation_folds'):
            self.resource_pool['cross-validation_folds'] = qids
        self.setQids(qids)
        self.results = {}
예제 #2
0
 def loadResources(self):
     """
     Loads the resources from the previously set resource pool.
     
     @raise Exception: when some of the resources required by the learner is not available in the ResourcePool object.
     """
     AbstractIterativeLearner.loadResources(self)
     
     Y = self.resource_pool['train_labels']
     self.Y = Y
     #Number of training examples
     self.size = Y.shape[0]
     if not Y.shape[1] == 1:
         raise Exception('GreedyRLS currently supports only one output at a time. The output matrix is now of shape ' + str(Y.shape) + '.')
     
     X = self.resource_pool['train_features']
     self.setDataMatrix(X.T)
     if self.resource_pool.has_key('bias'):
         self.bias = float(self.resource_pool['bias'])
     else:
         self.bias = 0.
     if self.resource_pool.has_key('measure'):
         self.measure = self.resource_pool['measure']
     else:
         self.measure = None
     qids = self.resource_pool['train_qids']
     if not self.resource_pool.has_key('cross-validation_folds'):
         self.resource_pool['cross-validation_folds'] = qids
     self.setQids(qids)
     self.results = {}
예제 #3
0
 def loadResources(self):
     AbstractIterativeLearner.loadResources(self)
     X = self.resource_pool[data_sources.TRAIN_FEATURES]
     if isinstance(X, sp.base.spmatrix):
         self.X = X.todense()
     else:
         self.X = X
     self.X = self.X.T
     self.Y = self.resource_pool[data_sources.TRAIN_LABELS]
     #Number of training examples
     self.size = self.Y.shape[0]
     #if not self.Y.shape[1] == 1:
     #    raise Exception('GreedyRLS currently supports only one output at a time. The output matrix is now of shape ' + str(self.Y.shape) + '.')
     if self.resource_pool.has_key('bias'):
         self.bias = float(self.resource_pool['bias'])
     else:
         self.bias = 0.
     if self.resource_pool.has_key(data_sources.PERFORMANCE_MEASURE):
         self.measure = self.resource_pool[data_sources.PERFORMANCE_MEASURE]
     else:
         self.measure = None
     self.results = {}