Spaces:
Sleeping
Sleeping
felipekitamura
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ def reduce_dimensions(data, method='PCA'):
|
|
14 |
if method == 'PCA':
|
15 |
model = PCA(n_components=2)
|
16 |
elif method == 'TSNE':
|
17 |
-
model = TSNE(n_components=2, learning_rate='auto', init='random', perplexity=
|
18 |
return model.fit_transform(data)
|
19 |
|
20 |
# Plotting function
|
@@ -74,9 +74,9 @@ def inference(word1, word2, word3):
|
|
74 |
data = np.concatenate([x[np.newaxis, :] for x in words.values()], axis=0)
|
75 |
print(data.shape)
|
76 |
labels = words.keys()
|
77 |
-
reduced_data_pca = reduce_dimensions(data, method='
|
78 |
print(reduced_data_pca.shape)
|
79 |
-
plot_reduced_data(reduced_data_pca, labels, '
|
80 |
return cache
|
81 |
|
82 |
examples = [
|
|
|
14 |
if method == 'PCA':
|
15 |
model = PCA(n_components=2)
|
16 |
elif method == 'TSNE':
|
17 |
+
model = TSNE(n_components=2, learning_rate='auto', init='random', perplexity=4)
|
18 |
return model.fit_transform(data)
|
19 |
|
20 |
# Plotting function
|
|
|
74 |
data = np.concatenate([x[np.newaxis, :] for x in words.values()], axis=0)
|
75 |
print(data.shape)
|
76 |
labels = words.keys()
|
77 |
+
reduced_data_pca = reduce_dimensions(data, method='TSNE')
|
78 |
print(reduced_data_pca.shape)
|
79 |
+
plot_reduced_data(reduced_data_pca, labels, 'TSNE Results')
|
80 |
return cache
|
81 |
|
82 |
examples = [
|