Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -22,9 +22,6 @@ import pandas as pd
|
|
| 22 |
from sklearn.manifold import TSNE
|
| 23 |
from sklearn.decomposition import PCA
|
| 24 |
import plotly.express as px
|
| 25 |
-
import plotly.graph_objects as go
|
| 26 |
-
import itertools
|
| 27 |
-
from plotly.colors import qualitative
|
| 28 |
|
| 29 |
# Load data
|
| 30 |
def load_data():
|
|
@@ -128,32 +125,29 @@ def plot_tsne(tech_filter, snr_filter, mod_filter, mob_filter, representation, c
|
|
| 128 |
x_pad = max(1e-3, (x_max - x_min) * 0.05)
|
| 129 |
y_pad = max(1e-3, (y_max - y_min) * 0.05)
|
| 130 |
|
| 131 |
-
# Plot (
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
marker=dict(size=6, opacity=0.8, color=color, line=dict(width=0)),
|
| 143 |
-
hovertext=filtered_df.loc[mask, ['tech', 'snr', 'mod', 'mob']].astype(str).agg('<br>'.join, axis=1),
|
| 144 |
-
hoverinfo='text'
|
| 145 |
-
))
|
| 146 |
-
fig.update_layout(
|
| 147 |
title=f"t-SNE of {representation} ({len(filtered_df)} samples)",
|
| 148 |
template="plotly_white",
|
| 149 |
-
|
| 150 |
-
margin=dict(l=40, r=20, t=60, b=40),
|
| 151 |
)
|
|
|
|
|
|
|
| 152 |
fig.update_xaxes(range=[x_min - x_pad, x_max + x_pad], zeroline=False)
|
| 153 |
fig.update_yaxes(range=[y_min - y_pad, y_max + y_pad], zeroline=False)
|
| 154 |
|
| 155 |
coord_info = f"x[{x_min:.3f},{x_max:.3f}] y[{y_min:.3f},{y_max:.3f}]"
|
| 156 |
-
|
|
|
|
| 157 |
|
| 158 |
# Convenience preset: single-tech, modulation-colored embedding view
|
| 159 |
def quick_modulation_plot():
|
|
|
|
| 22 |
from sklearn.manifold import TSNE
|
| 23 |
from sklearn.decomposition import PCA
|
| 24 |
import plotly.express as px
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Load data
|
| 27 |
def load_data():
|
|
|
|
| 125 |
x_pad = max(1e-3, (x_max - x_min) * 0.05)
|
| 126 |
y_pad = max(1e-3, (y_max - y_min) * 0.05)
|
| 127 |
|
| 128 |
+
# Plot (force serialization-friendly types)
|
| 129 |
+
plot_df = filtered_df.copy()
|
| 130 |
+
plot_df['x'] = plot_df['x'].astype(float)
|
| 131 |
+
plot_df['y'] = plot_df['y'].astype(float)
|
| 132 |
+
|
| 133 |
+
fig = px.scatter(
|
| 134 |
+
plot_df,
|
| 135 |
+
x='x',
|
| 136 |
+
y='y',
|
| 137 |
+
color=color_by,
|
| 138 |
+
hover_data=['tech', 'snr', 'mod', 'mob'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
title=f"t-SNE of {representation} ({len(filtered_df)} samples)",
|
| 140 |
template="plotly_white",
|
| 141 |
+
render_mode="webgl",
|
|
|
|
| 142 |
)
|
| 143 |
+
fig.update_layout(legend_title_text=color_by.capitalize(), margin=dict(l=40, r=20, t=60, b=40))
|
| 144 |
+
fig.update_traces(mode='markers', marker=dict(size=6, opacity=0.8, line=dict(width=0)))
|
| 145 |
fig.update_xaxes(range=[x_min - x_pad, x_max + x_pad], zeroline=False)
|
| 146 |
fig.update_yaxes(range=[y_min - y_pad, y_max + y_pad], zeroline=False)
|
| 147 |
|
| 148 |
coord_info = f"x[{x_min:.3f},{x_max:.3f}] y[{y_min:.3f},{y_max:.3f}]"
|
| 149 |
+
trace_info = f"traces: {len(fig.data)}"
|
| 150 |
+
return fig, f"{status_msg} | filtered samples: {len(filtered_df)} | {coord_info} | {trace_info}"
|
| 151 |
|
| 152 |
# Convenience preset: single-tech, modulation-colored embedding view
|
| 153 |
def quick_modulation_plot():
|