title: keyerror : word ' ' not in vocabulary WORD2VEC
body: <p><a href="https://i.stack.imgur.com/j25Yb.png" rel="nofollow noreferrer">enter image description here</a><a href="https://i.stack.imgur.com/WfMMM.png" rel="nofollow noreferrer">enter image description here</a>i'm working on Python Project and i'm using Word2Vec to recommend products.
  The code works absolutely fine for the data set containing 19401, but whenever i pass the id of the product i get <strong>this error &quot;keyerror : word '1077' not in vocabulary &quot;</strong> I don't know how to fix this problem since i have very little knowledge about it,,I am still learning.Please help me fix this problem!</p>
  <p>purchases_train = []</p>
  <pre><code>for i in tqdm(product_train):
      temp = train_df[train_df[&quot;Clothing ID&quot;] == i][&quot;Review Text&quot;].tolist()
      purchases_train.append(temp)
  
  
  purchases_val = []
  
  for i in tqdm(validation_df['Clothing ID'].unique()):
      temp = validation_df[validation_df[&quot;Clothing ID&quot;] == i][&quot;Review Text&quot;].tolist()
      purchases_val.append(temp)
  
  
  
  model = Word2Vec(window = 10, sg = 1, hs = 0,
                   negative = 10, # for negative sampling
                   alpha=0.03, min_count= 1 , min_alpha=0.0007,
                   seed = 14)
  
  
  model.build_vocab(purchases_train, progress_per=200)
  model.train(purchases_train, total_examples = model.corpus_count, 
              epochs=10, report_delay=1)
  
  # save word2vec model
  model.save(&quot;word2vec_2.model&quot;)
  
  
  model.init_sims(replace=True)
  
  # extract all vectors
  X = model[model.wv.vocab]
  
  products = train_df[[&quot;Clothing ID&quot;, &quot;Review Text&quot;]]
  
  # remove duplicates
  products.drop_duplicates(inplace=True, subset='Clothing ID', keep=&quot;last&quot;)
  
  # create product-ID and product-description dictionary
  products_dict = products.groupby('Clothing ID')['Review Text'].apply(list).to_dict()
  
  
  def similar_products(v, n = 6):
      
      # extract most similar products for the input vector
      ms = model.similar_by_vector(v, topn= n+1)[1:]
      
      # extract name and similarity score of the similar products
      new_ms = []
      for j in ms:
          pair = (products_dict[j[0]][0], j[1])
          new_ms.append(pair)
          
      return new_ms
  
  
  similar_products(model['1077'])
  </code></pre>