add rest of characteristics
Browse files- .gitignore +3 -1
- README.md +0 -0
- app.py +31 -1
- graphs/model_characteristics.py +79 -0
- start.sh +10 -0
.gitignore
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
venv/*
|
| 2 |
-
__pycache__
|
|
|
|
|
|
|
|
|
| 1 |
venv/*
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
| 4 |
+
graphs/__pycache__/model_characteristics.cpython-39.pyc
|
README.md
ADDED
|
File without changes
|
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import pandas as pd
|
|
| 4 |
import pickle
|
| 5 |
import plotly.express as px
|
| 6 |
from graphs.model_market_share import create_plotly_stacked_area_chart
|
| 7 |
-
from graphs.model_characteristics import create_plotly_language_concentration_chart
|
| 8 |
|
| 9 |
# Incorporate data
|
| 10 |
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv')
|
|
@@ -24,6 +24,10 @@ with open('data_frames/language_concentration_df.pkl', 'rb') as f:
|
|
| 24 |
language_concentration_df = pickle.load(f)
|
| 25 |
with open('data_frames/download_license_cumsum_df.pkl', 'rb') as f:
|
| 26 |
license_concentration_df = pickle.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
TEMP_MODEL_EVENTS = {
|
| 29 |
# "Yolo World Mirror": "2024-03-01",
|
|
@@ -72,10 +76,32 @@ fig3 = create_plotly_language_concentration_chart(
|
|
| 72 |
license_concentration_df, 'period', 'status', 'percent', LICENSE_SEGMENT_ORDER, PALETTE_0
|
| 73 |
)
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
# Make global font family
|
| 76 |
fig.update_layout(font_family="Inter")
|
| 77 |
fig2.update_layout(font_family="Inter")
|
| 78 |
fig3.update_layout(font_family="Inter")
|
|
|
|
|
|
|
| 79 |
|
| 80 |
# App layout
|
| 81 |
app.layout = html.Div(
|
|
@@ -108,6 +134,10 @@ def update_graph(selected_metric):
|
|
| 108 |
return fig2
|
| 109 |
elif selected_metric == 'License':
|
| 110 |
return fig3
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
# Run the app
|
| 113 |
if __name__ == '__main__':
|
|
|
|
| 4 |
import pickle
|
| 5 |
import plotly.express as px
|
| 6 |
from graphs.model_market_share import create_plotly_stacked_area_chart
|
| 7 |
+
from graphs.model_characteristics import create_plotly_language_concentration_chart, create_plotly_publication_curves_with_legend
|
| 8 |
|
| 9 |
# Incorporate data
|
| 10 |
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv')
|
|
|
|
| 24 |
language_concentration_df = pickle.load(f)
|
| 25 |
with open('data_frames/download_license_cumsum_df.pkl', 'rb') as f:
|
| 26 |
license_concentration_df = pickle.load(f)
|
| 27 |
+
with open('data_frames/download_method_cumsum_df.pkl', 'rb') as f:
|
| 28 |
+
download_method_cumsum_df = pickle.load(f)
|
| 29 |
+
with open('data_frames/download_arch_cumsum_df.pkl', 'rb') as f:
|
| 30 |
+
download_arch_cumsum_df = pickle.load(f)
|
| 31 |
|
| 32 |
TEMP_MODEL_EVENTS = {
|
| 33 |
# "Yolo World Mirror": "2024-03-01",
|
|
|
|
| 76 |
license_concentration_df, 'period', 'status', 'percent', LICENSE_SEGMENT_ORDER, PALETTE_0
|
| 77 |
)
|
| 78 |
|
| 79 |
+
METHOD_PLOT_CHOICES = {
|
| 80 |
+
"cumulative": "none", # none, mean, sum
|
| 81 |
+
"y_col": "percent", # percent count
|
| 82 |
+
"y_log": False, # True, False
|
| 83 |
+
"period": "W",
|
| 84 |
+
}
|
| 85 |
+
fig4 = create_plotly_publication_curves_with_legend(
|
| 86 |
+
download_method_cumsum_df, METHOD_PLOT_CHOICES, PALETTE_0
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
ARCHITECTURE_PLOT_CHOICES = {
|
| 90 |
+
"cumulative": "none", # none, mean, sum
|
| 91 |
+
"y_col": "percent", # percent count
|
| 92 |
+
"y_log": False, # True, False
|
| 93 |
+
"period": "W",
|
| 94 |
+
}
|
| 95 |
+
fig5 = create_plotly_publication_curves_with_legend(
|
| 96 |
+
download_arch_cumsum_df, ARCHITECTURE_PLOT_CHOICES, PALETTE_0
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
# Make global font family
|
| 100 |
fig.update_layout(font_family="Inter")
|
| 101 |
fig2.update_layout(font_family="Inter")
|
| 102 |
fig3.update_layout(font_family="Inter")
|
| 103 |
+
fig4.update_layout(font_family="Inter")
|
| 104 |
+
fig5.update_layout(font_family="Inter")
|
| 105 |
|
| 106 |
# App layout
|
| 107 |
app.layout = html.Div(
|
|
|
|
| 134 |
return fig2
|
| 135 |
elif selected_metric == 'License':
|
| 136 |
return fig3
|
| 137 |
+
elif selected_metric == 'Method':
|
| 138 |
+
return fig4
|
| 139 |
+
elif selected_metric == 'Architecture':
|
| 140 |
+
return fig5
|
| 141 |
|
| 142 |
# Run the app
|
| 143 |
if __name__ == '__main__':
|
graphs/model_characteristics.py
CHANGED
|
@@ -79,4 +79,83 @@ def create_plotly_language_concentration_chart(
|
|
| 79 |
gridwidth=1
|
| 80 |
)
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
return fig
|
|
|
|
| 79 |
gridwidth=1
|
| 80 |
)
|
| 81 |
|
| 82 |
+
return fig
|
| 83 |
+
|
| 84 |
+
def create_plotly_publication_curves_with_legend(
|
| 85 |
+
download_method_cumsum_df,
|
| 86 |
+
METHOD_PLOT_CHOICES,
|
| 87 |
+
color_palette=None
|
| 88 |
+
):
|
| 89 |
+
"""
|
| 90 |
+
Version with traditional legend instead of inline labels
|
| 91 |
+
"""
|
| 92 |
+
|
| 93 |
+
fig = go.Figure()
|
| 94 |
+
|
| 95 |
+
groups = download_method_cumsum_df['status'].unique()
|
| 96 |
+
|
| 97 |
+
if color_palette is None:
|
| 98 |
+
color_palette = px.colors.qualitative.Set1
|
| 99 |
+
|
| 100 |
+
for i, group in enumerate(groups):
|
| 101 |
+
group_data = download_method_cumsum_df[download_method_cumsum_df['status'] == group]
|
| 102 |
+
group_data = group_data.sort_values('period')
|
| 103 |
+
|
| 104 |
+
x_vals = group_data['period']
|
| 105 |
+
y_vals = group_data[METHOD_PLOT_CHOICES["y_col"]]
|
| 106 |
+
|
| 107 |
+
if METHOD_PLOT_CHOICES.get("y_format") == "percent":
|
| 108 |
+
y_vals = y_vals * 100
|
| 109 |
+
|
| 110 |
+
fig.add_trace(
|
| 111 |
+
go.Scatter(
|
| 112 |
+
x=x_vals,
|
| 113 |
+
y=y_vals,
|
| 114 |
+
name=group,
|
| 115 |
+
mode='lines',
|
| 116 |
+
line=dict(
|
| 117 |
+
color=color_palette[i % len(color_palette)],
|
| 118 |
+
width=3
|
| 119 |
+
),
|
| 120 |
+
opacity=0.85,
|
| 121 |
+
hovertemplate='<b>%{fullData.name}</b><br>' +
|
| 122 |
+
'Period: %{x}<br>' +
|
| 123 |
+
'Value: %{y:.2f}%<extra></extra>' if METHOD_PLOT_CHOICES.get("y_format") == "percent"
|
| 124 |
+
else '<b>%{fullData.name}</b><br>Period: %{x}<br>Value: %{y}<extra></extra>'
|
| 125 |
+
)
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
fig.update_layout(
|
| 129 |
+
width=1125,
|
| 130 |
+
height=225,
|
| 131 |
+
showlegend=True,
|
| 132 |
+
legend=dict(
|
| 133 |
+
orientation="h",
|
| 134 |
+
yanchor="bottom",
|
| 135 |
+
y=1.02,
|
| 136 |
+
xanchor="right",
|
| 137 |
+
x=1
|
| 138 |
+
),
|
| 139 |
+
margin=dict(l=60, r=60, t=60, b=60),
|
| 140 |
+
plot_bgcolor='white',
|
| 141 |
+
hovermode='x unified'
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
fig.update_xaxes(
|
| 145 |
+
title_text="Period",
|
| 146 |
+
showgrid=False,
|
| 147 |
+
zeroline=False
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
y_title = METHOD_PLOT_CHOICES["y_col"]
|
| 151 |
+
if METHOD_PLOT_CHOICES.get("y_format") == "percent":
|
| 152 |
+
y_title += " (%)"
|
| 153 |
+
|
| 154 |
+
fig.update_yaxes(
|
| 155 |
+
title_text=y_title,
|
| 156 |
+
showgrid=False,
|
| 157 |
+
zeroline=False,
|
| 158 |
+
type='log' if METHOD_PLOT_CHOICES.get("y_log") else 'linear'
|
| 159 |
+
)
|
| 160 |
+
|
| 161 |
return fig
|
start.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /bin/sh
|
| 2 |
+
|
| 3 |
+
# Create a virtual environment
|
| 4 |
+
python -m venv venv
|
| 5 |
+
source venv/bin/activate
|
| 6 |
+
pip install --upgrade pip
|
| 7 |
+
pip install -r requirements.txt
|
| 8 |
+
|
| 9 |
+
# Run the Dash app
|
| 10 |
+
python app.py
|