私は1列x行のSciPy csr_matrix(この場合ベクトル)を持っています。そこには浮動小数点値があります。これは、離散クラスラベル-1、0、1に変換する必要があります。これは浮動小数点値をこれらの3つのクラスラベルの1つにマップするしきい値関数で行う必要があります。 Iterating through a scipy.sparse vector (or matrix)に記載されているように
を初期化私はCOOフォーマットの3つの属性計算スクリプトを有する: data COO format data array of the matrix
row COO format row index array of the matrix
col COO format column index array of the matrix
を、私はcoo_matrixを初期化するために、これ
from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
from scipy.spatial import distance
X = CountVectorizer().fit_transform(docs)
X = TfidfTransformer(use_idf=False).fit_t
def get_column_normalized_matrix(A):
d=sp.csr_matrix.get_shape(A)[0]
Q=mat.zeros((d,d))
V=mat.zeros((1,d))
sp.csr_matrix.sum(A,axis=0,dtype='int',out=V)
for i in range(0,d):
def simrank_sparse(A,c,maxiter,eps=1e-4):
if not sp.issparse(A):
raise Exception("Input is not a sparse matrix ")
n=sp.csr_matrix.get_shape(A)[0]
Q=misc.get_column_normalized_ma