Exemplo n.º 1
0
    def reconstructMatrix(self, kSingularValues, returnMatrix=False):

        (sk, Uk, Vk) = self.decomposeTopK(kSingularValues)
        if (returnMatrix == True):
            return tsUtils.matrixFromSVD(sk, Uk, Vk)
        else:
            return (sk, Uk, Vk)
Exemplo n.º 2
0
    def denoisedTS(self, ind, range=True):

        NewColsDenoised = tsUtils.matrixFromSVD(self.sk,
                                                self.Uk,
                                                self.Vk,
                                                probability=self.p).flatten(1)
        if range:
            assert len(ind) == 2
            return NewColsDenoised[ind[0]:ind[1]]
        else:

            return NewColsDenoised[ind]
Exemplo n.º 3
0
    def denoisedDFNew(self,
                      D,
                      updateMethod='folding-in',
                      missingValueFill=True):
        assert (len(D) % self.N == 0)
        p = len(D) / self.N
        self.updateSVD(D, updateMethod)
        NewColsDenoised = tsUtils.matrixFromSVD(self.sk,
                                                self.Uk,
                                                self.Vk[-p:, :],
                                                probability=self.p)

        return NewColsDenoised.flatten(1)
Exemplo n.º 4
0
    def fit(self, keyToSeriesDF):

        # assign data to class variables
        self._assignData(keyToSeriesDF, missingValueFill=True)

        # now produce a thresholded/de-noised matrix. this will over-write the original data matrix
        svdMod = SVD(self.matrix, method='numpy')
        (self.sk, self.Uk, self.Vk) = svdMod.reconstructMatrix(self.kSingularValues, returnMatrix=False)

        self.matrix = tsUtils.matrixFromSVD(self.sk, self.Uk, self.Vk, probability=self.p)

        # set weights
        self._computeWeights()