Beispiel #1
0
    def initialization(self):
        # Fastmap like initialization
        # set the starting index for fastmap initialization
        cur_p = 0

        # after 3 iterations the first "real" index is found
        for i in range(3):
            d = self._distance(cur_p)
            cur_p = np.argmax(d)

        self.select = []
        self.select.append(cur_p)
        if self._compH:
            self.H = np.zeros((self._num_bases, self._num_samples))

        if self._compW:
            AA.initialization(self)
Beispiel #2
0
    def updateW(self):
        def selectHullPoints(data, n=3):
            """ select data points for pairwise projections of the first n
			dimensions """

            # iterate over all projections and select data points
            idx = np.array([])

            # iterate over some pairwise combinations of dimensions
            for i in combinations(range(n), 2):

                # sample convex hull points in 2D projection
                convex_hull_d = quickhull(data[i, :].T)

                # get indices for convex hull data points
                idx = np.append(idx, vq(data[i, :], convex_hull_d.T))
                idx = np.unique(idx)

            return np.int32(idx)

        # determine convex hull data points only if the total
        # amount of available data is >50
        #if self.data.shape[1] > 50:
        pcamodel = PCA(self.data, show_progress=self._show_progress)
        pcamodel.factorize()
        self._hull_idx = selectHullPoints(pcamodel.H, n=self._base_sel)

        #else:
        #	self._hull_idx = range(self.data.shape[1])

        aa_mdl = AA(self.data[:, self._hull_idx],
                    num_bases=self._num_bases,
                    niter=self._niter,
                    show_progress=self._show_progress,
                    compW=True)

        # initialize W, H, and beta
        aa_mdl.initialization()

        # determine W
        aa_mdl.factorize()

        self.W = aa_mdl.W