felipekitamura commited on
Commit
a7e2cd3
·
verified ·
1 Parent(s): 0e43ac7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -36,21 +36,21 @@ sp = gr.ScatterPlot(x="x", y="y", color="color")
36
  def inference(word1, word2, word3):
37
  output = model.similar_by_vector(model[word3] + model[word2] - model[word1])
38
  word_list = [word1, word2, word3]
39
- word_list.extend([x for x,y in output[:4]])
40
  words = {key: model[key] for key in word_list}
41
  data = np.concatenate([x[np.newaxis, :] for x in words.values()], axis=0)
42
  print(data.shape)
43
  labels = words.keys()
44
  reduced_data_pca = reduce_dimensions(data, method='PCA')
45
  print(reduced_data_pca.shape)
46
- '''
47
  df = pd.DataFrame({
48
  "x": reduced_data_pca[:, 0],
49
  "y": reduced_data_pca[:, 1],
50
  "color": ["b", "b", "b", "r", "g", "g", "g"]
51
  })
52
- '''
53
- return None #df
54
 
55
  examples = [
56
  ["woman", "man", "aunt"],
 
36
  def inference(word1, word2, word3):
37
  output = model.similar_by_vector(model[word3] + model[word2] - model[word1])
38
  word_list = [word1, word2, word3]
39
+ word_list.extend([x for x,y in [item for item in output[:4]]])
40
  words = {key: model[key] for key in word_list}
41
  data = np.concatenate([x[np.newaxis, :] for x in words.values()], axis=0)
42
  print(data.shape)
43
  labels = words.keys()
44
  reduced_data_pca = reduce_dimensions(data, method='PCA')
45
  print(reduced_data_pca.shape)
46
+ #'''
47
  df = pd.DataFrame({
48
  "x": reduced_data_pca[:, 0],
49
  "y": reduced_data_pca[:, 1],
50
  "color": ["b", "b", "b", "r", "g", "g", "g"]
51
  })
52
+ #'''
53
+ return df
54
 
55
  examples = [
56
  ["woman", "man", "aunt"],