divide by zero

This commit is contained in:
Alejandro Moreo Fernandez 2019-12-10 16:47:30 +01:00
parent 499c6018c0
commit 2bab6faf21
2 changed files with 1 additions and 0 deletions

View File

@ -12,6 +12,7 @@ def zscores(x, axis=0): #scipy.stats.zscores does not avoid division by 0, which
def supervised_embeddings_tfidf(X,Y): def supervised_embeddings_tfidf(X,Y):
tfidf_norm = X.sum(axis=0) tfidf_norm = X.sum(axis=0)
tfidf_norm[tfidf_norm==0] = 1
F = (X.T).dot(Y) / tfidf_norm.T F = (X.T).dot(Y) / tfidf_norm.T
return F return F

0
src/util/util.py Normal file
View File