Spaces:
Sleeping
Sleeping
Pragya Jatav
commited on
Commit
·
0a4f4cb
1
Parent(s):
3620944
m1
Browse files- Streamlit_functions.py +33 -3
- __pycache__/Streamlit_functions.cpython-310.pyc +0 -0
- __pycache__/classes.cpython-310.pyc +0 -0
- classes.py +13 -3
- pages/1_Model_Quality.py +1 -0
- summary_df.pkl +1 -1
Streamlit_functions.py
CHANGED
|
@@ -858,6 +858,35 @@ def media_data():
|
|
| 858 |
media_df = pd.DataFrame(extracted_data)
|
| 859 |
return media_df
|
| 860 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 861 |
|
| 862 |
def elasticity(media_df):
|
| 863 |
fig = go.Figure()
|
|
@@ -869,7 +898,7 @@ def elasticity(media_df):
|
|
| 869 |
orientation='h', # Setting the orientation to horizontal
|
| 870 |
marker_color='rgba(75, 136, 257, 1)',
|
| 871 |
text= media_df['coeff'].round(2),
|
| 872 |
-
textposition="
|
| 873 |
))
|
| 874 |
|
| 875 |
# Updating layout for better visualization
|
|
@@ -888,6 +917,7 @@ def elasticity(media_df):
|
|
| 888 |
gridcolor='gray', # Setting y-axis gridline color to gray
|
| 889 |
zeroline=False, # Hiding the y-axis zero line
|
| 890 |
),
|
|
|
|
| 891 |
# plot_bgcolor='black',
|
| 892 |
# paper_bgcolor='black',
|
| 893 |
# font=dict(color='lightgray') # Changing font color to white for better contrast
|
|
@@ -909,7 +939,7 @@ def half_life(media_df):
|
|
| 909 |
orientation='h', # Setting the orientation to horizontal
|
| 910 |
marker_color='rgba(75, 136, 257, 1)',
|
| 911 |
text= media_df['coeff'].round(2),
|
| 912 |
-
textposition="
|
| 913 |
))
|
| 914 |
|
| 915 |
# Updating layout for better visualization
|
|
@@ -927,7 +957,7 @@ def half_life(media_df):
|
|
| 927 |
showgrid=False,
|
| 928 |
gridcolor='gray', # Setting y-axis gridline color to gray
|
| 929 |
zeroline=False, # Hiding the y-axis zero line
|
| 930 |
-
),
|
| 931 |
# plot_bgcolor='black',
|
| 932 |
# paper_bgcolor='black',
|
| 933 |
# font=dict(color='lightgray') # Changing font color to white for better contrast
|
|
|
|
| 858 |
media_df = pd.DataFrame(extracted_data)
|
| 859 |
return media_df
|
| 860 |
|
| 861 |
+
def elasticity_and_media(media_df):
|
| 862 |
+
# Create subplots
|
| 863 |
+
fig = make_subplots(rows=1, cols=2, subplot_titles=("Chart 1", "Chart 2"))
|
| 864 |
+
fig.add_trace(
|
| 865 |
+
go.Bar(
|
| 866 |
+
x=media_df['coeff'],
|
| 867 |
+
y=media_df['category'],
|
| 868 |
+
orientation='h', # Setting the orientation to horizontal
|
| 869 |
+
marker_color='rgba(75, 136, 257, 1)',
|
| 870 |
+
text= media_df['coeff'].round(2),
|
| 871 |
+
textposition="outside"
|
| 872 |
+
),row=1, col=1
|
| 873 |
+
)
|
| 874 |
+
|
| 875 |
+
fig.add_trace(
|
| 876 |
+
go.Bar(
|
| 877 |
+
x=media_df[media_df['half_life'].isnull()==False]['half_life'],
|
| 878 |
+
y=media_df[media_df['half_life'].isnull()==False]['category'],
|
| 879 |
+
orientation='h', # Setting the orientation to horizontal
|
| 880 |
+
marker_color='rgba(75, 136, 257, 1)',
|
| 881 |
+
text= media_df['coeff'].round(2),
|
| 882 |
+
textposition="outside"
|
| 883 |
+
),row=1, col=2
|
| 884 |
+
)
|
| 885 |
+
fig.update_layout(
|
| 886 |
+
margin=dict(l=40, r=40, t=40, b=40), # Adjust the margins
|
| 887 |
+
)
|
| 888 |
+
|
| 889 |
+
return fig
|
| 890 |
|
| 891 |
def elasticity(media_df):
|
| 892 |
fig = go.Figure()
|
|
|
|
| 898 |
orientation='h', # Setting the orientation to horizontal
|
| 899 |
marker_color='rgba(75, 136, 257, 1)',
|
| 900 |
text= media_df['coeff'].round(2),
|
| 901 |
+
textposition="auto"
|
| 902 |
))
|
| 903 |
|
| 904 |
# Updating layout for better visualization
|
|
|
|
| 917 |
gridcolor='gray', # Setting y-axis gridline color to gray
|
| 918 |
zeroline=False, # Hiding the y-axis zero line
|
| 919 |
),
|
| 920 |
+
margin=dict(r=10)
|
| 921 |
# plot_bgcolor='black',
|
| 922 |
# paper_bgcolor='black',
|
| 923 |
# font=dict(color='lightgray') # Changing font color to white for better contrast
|
|
|
|
| 939 |
orientation='h', # Setting the orientation to horizontal
|
| 940 |
marker_color='rgba(75, 136, 257, 1)',
|
| 941 |
text= media_df['coeff'].round(2),
|
| 942 |
+
textposition="auto"
|
| 943 |
))
|
| 944 |
|
| 945 |
# Updating layout for better visualization
|
|
|
|
| 957 |
showgrid=False,
|
| 958 |
gridcolor='gray', # Setting y-axis gridline color to gray
|
| 959 |
zeroline=False, # Hiding the y-axis zero line
|
| 960 |
+
),margin=dict(l=20)
|
| 961 |
# plot_bgcolor='black',
|
| 962 |
# paper_bgcolor='black',
|
| 963 |
# font=dict(color='lightgray') # Changing font color to white for better contrast
|
__pycache__/Streamlit_functions.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/Streamlit_functions.cpython-310.pyc and b/__pycache__/Streamlit_functions.cpython-310.pyc differ
|
|
|
__pycache__/classes.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/classes.cpython-310.pyc and b/__pycache__/classes.cpython-310.pyc differ
|
|
|
classes.py
CHANGED
|
@@ -61,6 +61,7 @@ class Channel:
|
|
| 61 |
bounds,channel_bounds_min,channel_bounds_max,
|
| 62 |
conversion_rate=1,
|
| 63 |
modified_spends=None,
|
|
|
|
| 64 |
penalty=True,
|
| 65 |
):
|
| 66 |
self.name = name
|
|
@@ -74,6 +75,13 @@ class Channel:
|
|
| 74 |
else:
|
| 75 |
self.modified_spends = modified_spends
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
self.response_curve_type = response_curve_type
|
| 78 |
self.response_curve_params = response_curve_params
|
| 79 |
self.bounds = bounds
|
|
@@ -87,7 +95,7 @@ class Channel:
|
|
| 87 |
# self.actual_sales = self.response_curve(self.actual_spends)#sales.copy()#
|
| 88 |
self.actual_total_spends = self.actual_spends.sum()
|
| 89 |
self.actual_total_sales = self.actual_sales.sum()
|
| 90 |
-
|
| 91 |
self.modified_total_spends = self.modified_spends.sum()
|
| 92 |
self.modified_total_sales = self.modified_sales.sum()
|
| 93 |
self.delta_spends = self.modified_total_spends - self.actual_total_spends
|
|
@@ -266,8 +274,8 @@ class Scenario:
|
|
| 266 |
return total_modified_spends
|
| 267 |
|
| 268 |
def calculate_actual_total_sales(self):
|
| 269 |
-
total_actual_sales = 0
|
| 270 |
-
|
| 271 |
for channel in self.channels.values():
|
| 272 |
total_actual_sales += channel.actual_total_sales
|
| 273 |
# # print(channel.actual_total_sales)
|
|
@@ -275,7 +283,9 @@ class Scenario:
|
|
| 275 |
return total_actual_sales
|
| 276 |
|
| 277 |
def calculate_modified_total_sales(self):
|
|
|
|
| 278 |
total_modified_sales = 0 #self.constant.sum() + self.correction.sum()
|
|
|
|
| 279 |
for channel in self.channels.values():
|
| 280 |
# print(channel,channel.modified_total_sales)
|
| 281 |
total_modified_sales += channel.modified_total_sales
|
|
|
|
| 61 |
bounds,channel_bounds_min,channel_bounds_max,
|
| 62 |
conversion_rate=1,
|
| 63 |
modified_spends=None,
|
| 64 |
+
modified_sales=None,
|
| 65 |
penalty=True,
|
| 66 |
):
|
| 67 |
self.name = name
|
|
|
|
| 75 |
else:
|
| 76 |
self.modified_spends = modified_spends
|
| 77 |
|
| 78 |
+
if modified_sales is None:
|
| 79 |
+
# self.modified_sales = self.calculate_sales()
|
| 80 |
+
self.modified_sales = self.actual_sales.copy()
|
| 81 |
+
else:
|
| 82 |
+
self.modified_sales = self.calculate_sales()
|
| 83 |
+
# self.modified_spends = modified_spends
|
| 84 |
+
|
| 85 |
self.response_curve_type = response_curve_type
|
| 86 |
self.response_curve_params = response_curve_params
|
| 87 |
self.bounds = bounds
|
|
|
|
| 95 |
# self.actual_sales = self.response_curve(self.actual_spends)#sales.copy()#
|
| 96 |
self.actual_total_spends = self.actual_spends.sum()
|
| 97 |
self.actual_total_sales = self.actual_sales.sum()
|
| 98 |
+
|
| 99 |
self.modified_total_spends = self.modified_spends.sum()
|
| 100 |
self.modified_total_sales = self.modified_sales.sum()
|
| 101 |
self.delta_spends = self.modified_total_spends - self.actual_total_spends
|
|
|
|
| 274 |
return total_modified_spends
|
| 275 |
|
| 276 |
def calculate_actual_total_sales(self):
|
| 277 |
+
total_actual_sales = 0#self.constant.sum() + self.correction.sum()
|
| 278 |
+
print("a")
|
| 279 |
for channel in self.channels.values():
|
| 280 |
total_actual_sales += channel.actual_total_sales
|
| 281 |
# # print(channel.actual_total_sales)
|
|
|
|
| 283 |
return total_actual_sales
|
| 284 |
|
| 285 |
def calculate_modified_total_sales(self):
|
| 286 |
+
|
| 287 |
total_modified_sales = 0 #self.constant.sum() + self.correction.sum()
|
| 288 |
+
# print(total_modified_sales)
|
| 289 |
for channel in self.channels.values():
|
| 290 |
# print(channel,channel.modified_total_sales)
|
| 291 |
total_modified_sales += channel.modified_total_sales
|
pages/1_Model_Quality.py
CHANGED
|
@@ -20,6 +20,7 @@ col1, col2 = st.columns(2)
|
|
| 20 |
|
| 21 |
st.dataframe(sf.model_metrics_table_func(),hide_index = True,use_container_width=True)
|
| 22 |
|
|
|
|
| 23 |
with col1:
|
| 24 |
st.plotly_chart(sf.elasticity(media_df))
|
| 25 |
with col2:
|
|
|
|
| 20 |
|
| 21 |
st.dataframe(sf.model_metrics_table_func(),hide_index = True,use_container_width=True)
|
| 22 |
|
| 23 |
+
st.plotly_chart(sf.elasticity_and_media(media_df))
|
| 24 |
with col1:
|
| 25 |
st.plotly_chart(sf.elasticity(media_df))
|
| 26 |
with col2:
|
summary_df.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1822
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9b4eac3b946dbc2110dc592ef0ca72a418abaeddfca33d0f2c8dee3b2f4d3246
|
| 3 |
size 1822
|