Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,35 +27,21 @@ def plot_scatter(cat, x, y, col):
|
|
| 27 |
grouped_cat = data.groupby(["model", "tag"]).size().reset_index(name="count").sort_values(by="count", ascending=False)
|
| 28 |
grouped_cat["count"] = grouped_cat.groupby(["model"])["count"].transform(lambda x: x / x.sum())
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
pivot_df = grouped_cat.pivot(index='model', columns='tag', values='count').fillna(0)
|
| 32 |
-
|
|
|
|
| 33 |
if col == "Size":
|
| 34 |
-
pivot_df[col] = pivot_df
|
|
|
|
| 35 |
else:
|
| 36 |
-
pivot_df[col] = pivot_df
|
| 37 |
-
|
| 38 |
-
fig = px.scatter_3d(pivot_df, x=x, y=y, z=z,
|
| 39 |
-
hover_name="model",
|
| 40 |
-
title=f'{x} vs {y} vs {z}',
|
| 41 |
-
color=col,
|
| 42 |
-
color_continuous_scale="agsunset")
|
| 43 |
-
|
| 44 |
-
# # Pivot the data for stacking
|
| 45 |
-
# pivot_df = grouped_cat.pivot(index='model', columns='tag', values='count').fillna(0)
|
| 46 |
-
# # pivot_df = pivot_df.sort_values(by="A", ascending=False)
|
| 47 |
-
# # add color vis
|
| 48 |
-
# if col == "Size":
|
| 49 |
-
# pivot_df[col] = pivot_df.index.map(size_map)
|
| 50 |
-
# grouped_cat = grouped_cat.dropna(inplace=True)
|
| 51 |
-
# else:
|
| 52 |
-
# pivot_df[col] = pivot_df.index.str.split("/").str[0]
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
|
| 56 |
|
| 57 |
-
#
|
| 58 |
-
|
| 59 |
|
| 60 |
# Tab 3
|
| 61 |
def plot_scatter_tab3(subcat, col):
|
|
@@ -131,13 +117,6 @@ def plot_scatter_tab5(cat, x, y, z, col):
|
|
| 131 |
grouped_cat = data.groupby(["model", "tag"]).size().reset_index(name="count").sort_values(by="count", ascending=False)
|
| 132 |
grouped_cat["count"] = grouped_cat.groupby(["model"])["count"].transform(lambda x: x / x.sum())
|
| 133 |
|
| 134 |
-
# Pivot the data for stacking
|
| 135 |
-
# pivot_df = grouped_cat.pivot(index='model', columns='tag', values='count').fillna(0)
|
| 136 |
-
# if col == "Size":
|
| 137 |
-
# pivot_df[col] = pivot_df.index.map(size_map)
|
| 138 |
-
# else:
|
| 139 |
-
# pivot_df[col] = pivot_df.index.str.split("/").str[0]
|
| 140 |
-
|
| 141 |
pivot_df = grouped_cat.pivot(index='model', columns='tag', values='count').fillna(0).reset_index()
|
| 142 |
|
| 143 |
if col == "Size":
|
|
@@ -151,18 +130,10 @@ def plot_scatter_tab5(cat, x, y, z, col):
|
|
| 151 |
color=col,
|
| 152 |
color_continuous_scale="agsunset")
|
| 153 |
|
| 154 |
-
|
| 155 |
-
# Create an interactive scatter plot
|
| 156 |
-
# fig = px.scatter(pivot_df, x=x, y=y, hover_name=pivot_df.index, title=f'{x} vs {y}', color=col, color_continuous_scale="agsunset")
|
| 157 |
-
# fig = plt.figure()
|
| 158 |
-
|
| 159 |
-
# plot = px.scatter_3d(pivot_df[x], pivot_df[y], pivot_df[z]) #c=pivot_df[col], cmap='viridis')
|
| 160 |
print(pivot_df)
|
| 161 |
|
| 162 |
-
# fig = px.scatter_3d(pivot_df, x=x, y=y,z=z, hover_name=pivot_df.index, title=f'{x} vs {y} vs {z}', color=col, color_continuous_scale="agsunset")
|
| 163 |
return fig
|
| 164 |
|
| 165 |
-
|
| 166 |
# Tab 6
|
| 167 |
data_with_text = pd.read_csv("./tagged_data_with_text.csv")
|
| 168 |
def random_sample(r: gr.Request):
|
|
|
|
| 27 |
grouped_cat = data.groupby(["model", "tag"]).size().reset_index(name="count").sort_values(by="count", ascending=False)
|
| 28 |
grouped_cat["count"] = grouped_cat.groupby(["model"])["count"].transform(lambda x: x / x.sum())
|
| 29 |
|
| 30 |
+
# Pivot the data for stacking
|
| 31 |
+
pivot_df = grouped_cat.pivot(index='model', columns='tag', values='count').fillna(0)
|
| 32 |
+
# pivot_df = pivot_df.sort_values(by="A", ascending=False)
|
| 33 |
+
# add color vis
|
| 34 |
if col == "Size":
|
| 35 |
+
pivot_df[col] = pivot_df.index.map(size_map)
|
| 36 |
+
grouped_cat = grouped_cat.dropna(inplace=True)
|
| 37 |
else:
|
| 38 |
+
pivot_df[col] = pivot_df.index.str.split("/").str[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
# Create an interactive scatter plot
|
| 41 |
+
fig = px.scatter(pivot_df, x=x, y=y, hover_name=pivot_df.index, title=f'{x} vs {y}', color=col, color_continuous_scale="agsunset")
|
| 42 |
|
| 43 |
+
# Show the plot
|
| 44 |
+
return fig
|
| 45 |
|
| 46 |
# Tab 3
|
| 47 |
def plot_scatter_tab3(subcat, col):
|
|
|
|
| 117 |
grouped_cat = data.groupby(["model", "tag"]).size().reset_index(name="count").sort_values(by="count", ascending=False)
|
| 118 |
grouped_cat["count"] = grouped_cat.groupby(["model"])["count"].transform(lambda x: x / x.sum())
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
pivot_df = grouped_cat.pivot(index='model', columns='tag', values='count').fillna(0).reset_index()
|
| 121 |
|
| 122 |
if col == "Size":
|
|
|
|
| 130 |
color=col,
|
| 131 |
color_continuous_scale="agsunset")
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
print(pivot_df)
|
| 134 |
|
|
|
|
| 135 |
return fig
|
| 136 |
|
|
|
|
| 137 |
# Tab 6
|
| 138 |
data_with_text = pd.read_csv("./tagged_data_with_text.csv")
|
| 139 |
def random_sample(r: gr.Request):
|