skills_ml/algorithms/embedding/models.py
def infer_vector(self, doc_words, warning=False):
         """
         Average all the word-vectors together and ignore the unseen words
         """
         sum_vector = np.zeros(self.vector_size)
         words_in_vocab = []
         for token in doc_words:
             try:
                 sum_vector += self[token]
                 words_in_vocab.append(token)
             except KeyError as e:
                 if warning:
                    logging.warning("".join([str(e), ". Ignore the word."]))
                 pass

         if len(words_in_vocab) == 0:
             logging.warning("None of the words is in vocabulary.")
             return np.random.rand(self.vector_size)
         sentence_vector = sum_vector / len(words_in_vocab)
         return sentence_vector

         Average all the word-vectors together and ignore the unseen words
         
Average all the word-vectors together and ignore the unseen words
Average all the word - vectors together and ignore the unseen words
def infer_vector(self, doc_words, warning=False):
         sum_vector = np.zeros(self.vector_size)
         words_in_vocab = []
         for token in doc_words:
             try:
                 sum_vector += self[token]
                 words_in_vocab.append(token)
             except KeyError as e:
                 if warning:
                    logging.warning("".join([str(e), ". Ignore the word."]))
                 pass
         if len(words_in_vocab) == 0:
             logging.warning("None of the words is in vocabulary.")
             return np.random.rand(self.vector_size)
         sentence_vector = sum_vector / len(words_in_vocab)
         return sentence_vector
def infer_vector ( self , doc_words , warning = False ) : sum_vector = np . zeros ( self . vector_size ) words_in_vocab = [ ] for token in doc_words : try : sum_vector += self [ token ] words_in_vocab . append ( token ) except KeyError as e : if warning : logging . warning ( "" . join ( [ str ( e ) , ". Ignore the word." ] ) ) pass if len ( words_in_vocab ) == 0 : logging . warning ( "None of the words is in vocabulary." ) return np . random . rand ( self . vector_size ) sentence_vector = sum_vector / len ( words_in_vocab ) return sentence_vector
Average all the word-vectors together and ignore the unseen words
Average all the word - vectors together and ignore the unseen words
"""
         Average all the word-vectors together and ignore the unseen words
         """
self
doc_words
warning