Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?

私のブログが引用されているこんな記事 (未解決)大規模疎行列のコサイン類似度 – studylog/北の雲 を見つけたので乗っかってみる。しかも、未解決って書いてあるし。 文書群データが疎行列\(A\)で与えられているとする。ここで、各行が文書を、各列が語を表しているとする。ここで文書間のコサイン類似度を総当りで計算したいものとして、その方法を示す。 \(A\)の各行をベクトルと見てL2ノルムで正規化したものを\(\tilde{A}\)とすると、コサイン類似度を示す行列は \[ \tilde{A} \tilde{A}^T \] で計算できる。 では\(\tilde{A}\)をどう計算するかだが、ブロードキャスティングを使ってインプレイスで求めるのがいいかと思う。以下にサンプルコードを示す。 from scipy.sparse import lil_matrix import numpy a
numpy.random.randint¶ numpy.random.randint(low, high=None, size=None, dtype='l')¶ Return random integers from low (inclusive) to high (exclusive). Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low). low : int Lowest (signed) integer to be drawn from the distrib
numpy.nan_to_num# numpy.nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None)[source]# Replace NaN with zero and infinity with large finite numbers (default behaviour) or with the numbers defined by the user using the nan, posinf and/or neginf keywords. If x is inexact, NaN is replaced by zero or by the user defined value in nan keyword, infinity is replaced by the largest finite floating po
numpy.matrix# class numpy.matrix(data, dtype=None, copy=True)[source]# Returns a matrix from an array-like object, or from a string of data. A matrix is a specialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as * (matrix multiplication) and ** (matrix power). Note It is no longer recommended to use this class, even for linear algebra. Instead
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く