Update app.py
Browse files
app.py
CHANGED
@@ -330,15 +330,15 @@ def visualize_results(results_df, stats_df):
|
|
330 |
axs[1, 0].set_title('Distribution of Result Content Lengths')
|
331 |
axs[1, 0].set_xticklabels(axs[1, 0].get_xticklabels(), rotation=45, ha='right')
|
332 |
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
|
343 |
plt.tight_layout()
|
344 |
return fig
|
|
|
330 |
axs[1, 0].set_title('Distribution of Result Content Lengths')
|
331 |
axs[1, 0].set_xticklabels(axs[1, 0].get_xticklabels(), rotation=45, ha='right')
|
332 |
|
333 |
+
embeddings = np.array([embedding for embedding in results_df['embedding'] if isinstance(embedding, np.ndarray)])
|
334 |
+
if len(embeddings) > 1:
|
335 |
+
tsne = TSNE(n_components=2, random_state=42)
|
336 |
+
embeddings_2d = tsne.fit_transform(embeddings)
|
337 |
+
|
338 |
+
sns.scatterplot(x=embeddings_2d[:, 0], y=embeddings_2d[:, 1], hue=results_df['model'][:len(embeddings)], ax=axs[1, 1])
|
339 |
+
axs[1, 1].set_title('t-SNE Visualization of Result Embeddings')
|
340 |
+
else:
|
341 |
+
axs[1, 1].text(0.5, 0.5, "Not enough data for t-SNE visualization", ha='center', va='center')
|
342 |
|
343 |
plt.tight_layout()
|
344 |
return fig
|