Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# TF
aa = bow.copy()
np.set_printoptions(threshold=np.inf,formatter={'float': '{:.8f}'.format})
for i in range(0,dim[0]):
ar = bow.getrow(i)
rowsum = np.matrix.sum(ar.todense())
arr = ar/rowsum
aa[i] = arr
# IDF(ln)
for j in range(0,dim[1]):
ac = aa.getcol(j)
idf = math.log(dim[0]/ac.getnnz())
aa[0:dim[0],j] = ac*idf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment