Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
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"],
|