示例#1
0
 def loadResources(self):
     AbstractIterativeLearner.loadResources(self)
     AbstractSupervisedLearner.loadResources(self)
     #Y = self.resource_pool[data_sources.TRAIN_LABELS]
     #self.setLabels(Y)
     X = self.resource_pool[data_sources.TRAIN_FEATURES]
     self.X = csc_matrix(X.T)
     if self.resource_pool.has_key('bias'):
         self.bias = float(self.resource_pool['bias'])
         if self.bias != 0.:
             bias_slice = sqrt(self.bias)*np.mat(ones((1,self.X.shape[1]),dtype=np.float64))
             self.X = sparse.vstack([self.X,bias_slice]).tocsc()
     else:
         self.bias = 0.
     self.X_csr = self.X.tocsr()
     if (data_sources.VALIDATION_FEATURES in self.resource_pool) and (data_sources.VALIDATION_LABELS in self.resource_pool):
         validation_X = self.resource_pool[data_sources.VALIDATION_FEATURES]
         validation_Y = self.resource_pool[data_sources.VALIDATION_LABELS]
         self.callbackfun = EarlyStopCB(validation_X, validation_Y)
示例#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)
     AbstractSupervisedLearner.loadResources(self)
     
     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']
     if isinstance(X, scipy.sparse.base.spmatrix):
         self.X = X.todense()
     else:
         self.X = X
    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)
        AbstractSupervisedLearner.loadResources(self)

        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"]
        if isinstance(X, scipy.sparse.base.spmatrix):
            self.X = X.todense()
        else:
            self.X = X