Ejemplo n.º 1
0
    def _train(self, dataset):
        """Determine the projection matrix onto the components from
        a 2D samples x feature data matrix.
        """
        white_param = {}

        # more features than samples? -> rank deficiancy
        # if not tranposing the data, MDP has to do SVD prior to ICA
        if dataset.samples.shape[1] > dataset.samples.shape[0] \
           and not self._transpose:
            white_param['svd'] = True

        if self._algorithm == 'fastica':
            node = FastICANode(white_parm=white_param,
                               dtype=dataset.samples.dtype)
        elif self._algorithm == 'cubica':
            node = CuBICANode(white_parm=white_param,
                              dtype=dataset.samples.dtype)
        else:
            raise NotImplementedError

#            node.train(dataset.samples.T)
#            self._proj = dataset.samples.T * N.asmatrix(node.get_projmatrix())
#            print self._proj.shape
#        else:
        node.train(dataset.samples)
        self._proj = N.asmatrix(node.get_projmatrix())
        self._recon = N.asmatrix(node.get_recmatrix())