def train(self, k_factors=300):
        """
        Trains the model.

        :param k_factors: Default is 300.
        :type k_factors: int, optional
        """
        from scipy.sparse import linalg as linalgs

        u,s,v = np.array([]), np.array([]), np.array([])

        if self.td_matrix.size > 0:
            s = min(self.td_matrix.shape)
            if s < k_factors:
                k_factors = s - 1

            # print 'Performing sparse SVD'
            u, s, v = linalgs.svds(self.td_matrix, k=k_factors)

        indices = s.argsort()[::-1]
        self.word_matrix = u[:, indices]
        self.eigenvalues = s[indices]
        self.doc_matrix = v[indices, :]
dataset/ETHPy150Open inpho/vsm/vsm/model/lsa.py/Lsa.train/original