Merge remote-tracking branch 'origin/master'

This commit is contained in:
andrea 2019-12-12 14:34:54 +01:00
commit 174aa8ca05
3 changed files with 3 additions and 0 deletions

View File

@ -276,6 +276,7 @@ class StorageEmbeddings:
self._add_emebeddings_supervised(docs, labels, config['reduction'], config['max_label_space'], vocs) self._add_emebeddings_supervised(docs, labels, config['reduction'], config['max_label_space'], vocs)
return self return self
def predict(self, config, docs): def predict(self, config, docs):
if config['supervised'] and config['unsupervised']: if config['supervised'] and config['unsupervised']:
return self._concatenate_embeddings(docs) return self._concatenate_embeddings(docs)
@ -288,3 +289,4 @@ class StorageEmbeddings:
for lang in docs.keys(): for lang in docs.keys():
_r[lang] = docs[lang].dot(self.lang_U[lang]) _r[lang] = docs[lang].dot(self.lang_U[lang])
return _r return _r

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