start tree map
Browse files- app.py +8 -0
- graphs/leaderboard.py +6 -2
- graphs/tree.py +15 -0
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import pandas as pd
|
|
| 3 |
from graphs.model_market_share import create_stacked_area_chart, create_world_map, create_range_slider
|
| 4 |
from graphs.leaderboard import create_leaderboard
|
| 5 |
from graphs.model_characteristics import create_concentration_chart, create_line_plot
|
|
|
|
| 6 |
|
| 7 |
# Initialize the app
|
| 8 |
app = Dash()
|
|
@@ -105,6 +106,10 @@ download_arch_cumsum_line = create_line_plot(
|
|
| 105 |
download_arch_cumsum_df, ARCHITECTURE_PLOT_CHOICES, PALETTE_0
|
| 106 |
)
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
# App layout
|
| 109 |
app.layout = html.Div(
|
| 110 |
[
|
|
@@ -181,6 +186,9 @@ app.layout = html.Div(
|
|
| 181 |
filtered_df, country_concentration_df, author_concentration_df, model_concentration_df
|
| 182 |
)
|
| 183 |
]),
|
|
|
|
|
|
|
|
|
|
| 184 |
dcc.Tab(label='Model Characteristics', children=[
|
| 185 |
dcc.Graph(id='language-concentration-chart'),
|
| 186 |
html.Div([
|
|
|
|
| 3 |
from graphs.model_market_share import create_stacked_area_chart, create_world_map, create_range_slider
|
| 4 |
from graphs.leaderboard import create_leaderboard
|
| 5 |
from graphs.model_characteristics import create_concentration_chart, create_line_plot
|
| 6 |
+
from graphs.tree import generate_model_treemap
|
| 7 |
|
| 8 |
# Initialize the app
|
| 9 |
app = Dash()
|
|
|
|
| 106 |
download_arch_cumsum_df, ARCHITECTURE_PLOT_CHOICES, PALETTE_0
|
| 107 |
)
|
| 108 |
|
| 109 |
+
tree_map = generate_model_treemap(
|
| 110 |
+
filtered_df
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
# App layout
|
| 114 |
app.layout = html.Div(
|
| 115 |
[
|
|
|
|
| 186 |
filtered_df, country_concentration_df, author_concentration_df, model_concentration_df
|
| 187 |
)
|
| 188 |
]),
|
| 189 |
+
dcc.Tab(label='Model Tree Map', children=[
|
| 190 |
+
dcc.Graph(figure=tree_map)
|
| 191 |
+
]),
|
| 192 |
dcc.Tab(label='Model Characteristics', children=[
|
| 193 |
dcc.Graph(id='language-concentration-chart'),
|
| 194 |
html.Div([
|
graphs/leaderboard.py
CHANGED
|
@@ -35,7 +35,7 @@ def create_leaderboard(filtered_df, country_df, developer_df, model_df, start_ti
|
|
| 35 |
|
| 36 |
# Merge country info for developers/models
|
| 37 |
developer_df = developer_df.merge(
|
| 38 |
-
filtered_df[["country", "author", "org_or_user", "model"]].drop_duplicates(subset=["author"]),
|
| 39 |
left_on="metric", right_on="author", how="left"
|
| 40 |
).drop(columns=["metric"])
|
| 41 |
|
|
@@ -45,7 +45,11 @@ def create_leaderboard(filtered_df, country_df, developer_df, model_df, start_ti
|
|
| 45 |
).drop(columns=["metric"])
|
| 46 |
|
| 47 |
# Rename metric columns
|
| 48 |
-
country_df = country_df.rename(columns={"metric": "country"})
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
# Filter by time
|
| 51 |
start_time = start_time or country_df["time"].min()
|
|
|
|
| 35 |
|
| 36 |
# Merge country info for developers/models
|
| 37 |
developer_df = developer_df.merge(
|
| 38 |
+
filtered_df[["country", "author", "org_or_user", "model", "downloads"]].drop_duplicates(subset=["author"]),
|
| 39 |
left_on="metric", right_on="author", how="left"
|
| 40 |
).drop(columns=["metric"])
|
| 41 |
|
|
|
|
| 45 |
).drop(columns=["metric"])
|
| 46 |
|
| 47 |
# Rename metric columns
|
| 48 |
+
# country_df = country_df.rename(columns={"metric": "country"})
|
| 49 |
+
country_df = country_df.merge(
|
| 50 |
+
filtered_df[["country", "downloads"]].drop_duplicates(subset=["country"]),
|
| 51 |
+
left_on="metric", right_on="country", how="left"
|
| 52 |
+
).drop(columns=["metric"])
|
| 53 |
|
| 54 |
# Filter by time
|
| 55 |
start_time = start_time or country_df["time"].min()
|
graphs/tree.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import plotly.express as px
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
def generate_model_treemap(df, parent_col='merged_derived_from', child_col='model', value_col='downloads'):
|
| 5 |
+
df[parent_col] = str(df[parent_col][0])
|
| 6 |
+
|
| 7 |
+
fig = px.treemap(
|
| 8 |
+
df,
|
| 9 |
+
path=[parent_col, child_col],
|
| 10 |
+
values=value_col,
|
| 11 |
+
hover_data=['author', 'estimated_parameters', 'created'],
|
| 12 |
+
color=value_col,
|
| 13 |
+
color_continuous_scale='Viridis'
|
| 14 |
+
)
|
| 15 |
+
return fig
|