def randomizedSVD(self):
# http://scikit-learn.org/stable/modules/decomposition.html#truncated-singular-value-decomposition-and-latent-semantic-analysis
# http://stackoverflow.com/questions/31523575/get-u-sigma-v-matrix-from-truncated-svd-in-scikit-learn
U, S, V = randomized_svd(self.bag_of_words_matrix.T,
n_components=self.dimensions,
n_iter=5,
random_state=None)
self.U = U
self.S = S
self.V = V
self.tokens_representation = np.matrix(U) * np.diag(S)
self.documents_representation = (np.diag(S) * np.matrix(V)).T
评论列表
文章目录