Manoj commited on
Commit
16e3779
β€’
1 Parent(s): 8c43e79
Overview_data_test_panel@#prospects.xlsx ADDED
Binary file (131 kB). View file
 
Overview_data_test_panel@#revenue.xlsx DELETED
Binary file (407 kB)
 
README.md CHANGED
@@ -5,7 +5,7 @@ colorFrom: indigo
5
  colorTo: pink
6
  sdk: streamlit
7
  sdk_version: 1.32.1
8
- app_file: Model_Result_Overview.py
9
  pinned: false
10
  ---
11
 
 
5
  colorTo: pink
6
  sdk: streamlit
7
  sdk_version: 1.32.1
8
+ app_file: Scenario_Planner.py
9
  pinned: false
10
  ---
11
 
pages/8_Scenario_Planner.py β†’ Scenario_Planner.py RENAMED
@@ -1007,7 +1007,7 @@ if auth_status == True:
1007
  # on_change=reset_inputs,
1008
  # )
1009
 
1010
- metrics_selected='revenue'
1011
  # Target
1012
  target = name_formating(metrics_selected)
1013
 
@@ -1483,34 +1483,34 @@ if auth_status == True:
1483
  unsafe_allow_html=True,
1484
  )
1485
 
1486
- with st.expander("See Response Curves", expanded=True):
1487
- fig = plot_response_curves()
1488
- st.plotly_chart(fig, use_container_width=True)
1489
-
1490
- _columns = st.columns(2)
1491
- # with _columns[0]:
1492
- st.subheader("Save Scenario")
1493
- scenario_name = st.text_input(
1494
- "Scenario name",
1495
- key="scenario_input",
1496
- placeholder="Scenario name",
1497
- label_visibility="collapsed",
1498
- )
1499
- st.button(
1500
- "Save",
1501
- on_click=lambda: save_scenario(scenario_name),
1502
- disabled=len(st.session_state["scenario_input"]) == 0,use_container_width=True
1503
- )
1504
 
1505
- summary_df = pd.DataFrame(st.session_state["acutual_predicted"])
1506
- summary_df.drop_duplicates(subset="Channel_name", keep="last", inplace=True)
1507
 
1508
- summary_df_sorted = summary_df.sort_values(by="Delta", ascending=False)
1509
- summary_df_sorted["Delta_percent"] = np.round(
1510
- ((summary_df_sorted["Optimized_spend"] / summary_df_sorted["Actual_spend"]) - 1)
1511
- * 100,
1512
- 2,
1513
- )
1514
 
1515
  with open("summary_df.pkl", "wb") as f:
1516
  pickle.dump(summary_df_sorted, f)
 
1007
  # on_change=reset_inputs,
1008
  # )
1009
 
1010
+ metrics_selected='prospects'
1011
  # Target
1012
  target = name_formating(metrics_selected)
1013
 
 
1483
  unsafe_allow_html=True,
1484
  )
1485
 
1486
+ # with st.expander("See Response Curves", expanded=True):
1487
+ # fig = plot_response_curves()
1488
+ # st.plotly_chart(fig, use_container_width=True)
1489
+
1490
+ # _columns = st.columns(2)
1491
+ # # with _columns[0]:
1492
+ # st.subheader("Save Scenario")
1493
+ # scenario_name = st.text_input(
1494
+ # "Scenario name",
1495
+ # key="scenario_input",
1496
+ # placeholder="Scenario name",
1497
+ # label_visibility="collapsed",
1498
+ # )
1499
+ # st.button(
1500
+ # "Save",
1501
+ # on_click=lambda: save_scenario(scenario_name),
1502
+ # disabled=len(st.session_state["scenario_input"]) == 0,use_container_width=True
1503
+ # )
1504
 
1505
+ # summary_df = pd.DataFrame(st.session_state["acutual_predicted"])
1506
+ # summary_df.drop_duplicates(subset="Channel_name", keep="last", inplace=True)
1507
 
1508
+ # summary_df_sorted = summary_df.sort_values(by="Delta", ascending=False)
1509
+ # summary_df_sorted["Delta_percent"] = np.round(
1510
+ # ((summary_df_sorted["Optimized_spend"] / summary_df_sorted["Actual_spend"]) - 1)
1511
+ # * 100,
1512
+ # 2,
1513
+ # )
1514
 
1515
  with open("summary_df.pkl", "wb") as f:
1516
  pickle.dump(summary_df_sorted, f)
Test/output_df.csv CHANGED
@@ -1,29 +1,105 @@
1
- Date,const,TV,Radio,Online-Search,Online-Social,Online-Display
2
- 2023-10-06,5600,59756.0844,142203.9149,28601.88742,50917.24656,33.0
3
- 2023-10-07,5600,4729.790691,13687.27868,4533.499686,4661.526339,28.99845778
4
- 2023-10-08,5600,3813.711153,13169.55523,2333.559147,4516.38624,28.99845778
5
- 2023-10-09,5600,2914.944625,12174.66075,2333.559147,4458.082645,31.00582633
6
- 2023-10-10,5600,2397.607895,11382.13944,866.696237,4633.786327,36.57315649
7
- 2023-10-11,5600,2030.213987,11728.5212,4753.433627,4344.815321,42.85967447
8
- 2023-10-12,5600,1830.984812,12685.90092,3927.458,3674.378572,38.21471097
9
- 2023-10-13,5600,1579.931074,12929.94788,2769.207621,3563.619842,37.97022099
10
- 2023-10-14,5600,1751.457923,12334.35123,4654.32756,4076.330336,44.67969146
11
- 2023-10-15,5600,1553.758322,12366.09162,4390.452107,3972.140169,16.3174922
12
- 2023-10-16,5600,2157.741503,11953.27821,3528.841092,3810.866204,73.52925638
13
- 2023-10-17,5600,2733.488482,11421.58186,2940.240073,3989.162779,83.23761245
14
- 2023-10-18,5600,2648.588677,11990.4392,5147.61113,3878.666893,72.9103301
15
- 2023-10-19,5600,2608.080302,13763.92965,3745.619183,3766.169273,84.58450258
16
- 2023-10-20,5600,2100.502694,13922.19601,4523.837232,3767.96304,67.10249285
17
- 2023-10-21,5600,1644.795022,14150.51864,9221.915556,4055.068091,95.52759293
18
- 2023-10-22,5600,1389.7598,13870.93312,9662.813263,3962.727124,134.4031803
19
- 2023-10-23,5600,1417.564395,14228.28115,10634.54798,4086.60496,160.3349289
20
- 2023-10-24,5600,1332.448786,14092.05212,8761.717336,4830.23677,176.6417753
21
- 2023-10-25,5600,1216.112934,11929.61991,5451.34576,4850.424513,131.0169787
22
- 2023-10-26,5600,1299.676521,11481.0426,5823.157794,4887.425273,101.2440651
23
- 2023-10-27,5600,1252.148046,11147.22245,7472.096231,4618.373003,119.262777
24
- 2023-10-28,5600,1008.991192,10861.33851,9926.506067,4096.021098,141.6552351
25
- 2023-10-29,5600,613.6573777,10198.12195,9518.260835,3955.613007,103.2800534
26
- 2023-10-31,5600,759.640851,9587.491629,5732.041097,4000.988498,135.3865979
27
- 2023-11-01,5600,463.7423486,8843.578375,4130.304272,4208.795409,107.1697328
28
- 2023-11-02,5600,412.8694761,9230.788309,3449.601815,4319.461496,104.2554932
29
- 2023-11-03,5600,150.5666759,9532.980532,5166.812906,3988.123646,98.15641792
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Date,const,BroadcastTV,CableTV,Connected&OTTTV,DisplayProspecting,DisplayRetargeting,Β Video,SocialProspecting,SocialRetargeting,SearchBrand,SearchNon-brand,DigitalPartners,Audio,Email
2
+ 2022-02-27,1,605.7688941,880.7115151,135.0516981,208.2711327,19.41746001,297.0007496,345.010799,51.00935797,214.3019417,892.607461,833.4551364,316.7036224,0.0
3
+ 2022-03-06,1,779.587861,837.4491512,157.5004969,207.4753074,79.15177069,392.480332,343.428751,50.4354065,219.5135831,875.611235,819.5548137,315.3451715,0.0
4
+ 2022-03-13,1,864.7806971,954.5658374,187.947124,221.713362,76.2604722,468.6212166,366.996612,67.83612655,234.9089159,901.5223839,875.796913,336.9854082,0.0
5
+ 2022-03-20,1,731.3285906,936.5859186,196.7562215,227.2802865,62.379592,339.6859962,376.2114027,82.22335436,240.9831858,932.7780942,897.7869942,345.4468683,0.0
6
+ 2022-03-27,1,686.1206578,918.340495,209.7801073,208.7921837,27.39101731,164.8588646,345.6085063,79.3408774,221.3853364,991.6264718,789.6958012,317.3467101,0.0
7
+ 2022-04-03,1,690.8365006,809.1925488,228.8269719,180.9403061,22.82948094,190.2177151,299.5059862,53.00895811,191.8827057,1098.987071,605.7673405,275.0141765,0.0
8
+ 2022-04-10,1,720.8362641,735.4593072,225.7303976,173.9216886,24.71429802,139.7027908,287.8882436,44.87884693,184.4272411,984.3838731,582.2698163,264.3464426,0.0
9
+ 2022-04-17,1,775.4075191,796.3286979,227.1361474,184.1782682,20.09658828,185.1578527,304.8657049,49.54791165,195.3077905,992.5354147,616.6076663,279.9348206,0.0
10
+ 2022-04-24,1,835.5742747,795.138986,203.775006,194.3528204,30.77660161,197.2930056,321.7073877,54.16304355,206.1241222,1127.671193,650.6708965,295.3997591,0.0
11
+ 2022-05-01,1,778.4072046,800.3858887,209.6706691,187.8029139,14.68086209,117.0588368,310.8654904,48.92250172,199.1598609,1522.512401,573.2443965,285.4445468,0.0
12
+ 2022-05-08,1,888.1079123,918.5182742,230.406251,207.458539,6.824600634,105.0858789,343.4009675,57.14979371,220.0015126,1502.533433,633.2406986,315.3190743,0.0
13
+ 2022-05-15,1,942.8699373,927.5320449,231.7409952,219.2881419,5.789528794,103.0402573,362.9822054,58.18594974,232.5560247,1604.383918,669.3490323,333.2967868,0.0
14
+ 2022-05-22,1,885.4667828,886.484453,205.2506739,206.7666081,10.84383167,60.95975874,342.2556214,44.88531703,219.249405,1285.973994,631.1286493,314.2363601,0.0
15
+ 2022-05-29,1,872.1263477,819.8747129,211.6585103,203.0097861,32.79210764,170.5377143,336.0370474,32.71797255,215.2991394,1159.99767,590.7548479,308.5578319,0.0
16
+ 2022-06-05,1,850.0419903,833.2096897,239.4503592,196.9778946,30.43141305,86.116707,326.0526075,33.33021252,208.8987866,1289.817117,551.8094443,299.3899667,0.0
17
+ 2022-06-12,1,899.3901532,898.3532455,305.2964146,208.0552874,37.41568812,114.7826432,344.3887402,41.13349708,220.6385363,1252.42105,582.8414035,316.2265328,0.0
18
+ 2022-06-19,1,890.7498196,863.113055,347.5208084,211.5952537,44.94118232,180.9492415,350.2483583,53.12879903,224.3962372,1261.189978,592.7581854,321.6060907,0.0
19
+ 2022-06-26,1,783.8586228,851.2196504,300.3451176,203.3583296,28.70458021,125.5195234,336.6139827,78.56584301,215.605161,1234.200295,562.5795688,309.0877084,0.0
20
+ 2022-07-03,1,623.6384606,840.8641099,324.3629383,202.3052943,240.2171456,95.76678262,334.8709197,127.4832436,214.5120877,1204.274958,541.8456282,307.4871828,0.0
21
+ 2022-07-10,1,570.9534282,810.5012067,310.9911019,190.8623186,400.769678,57.01233229,315.9296467,108.8375367,202.3840169,1278.989752,511.1972638,290.0948136,0.0
22
+ 2022-07-17,1,565.9144673,868.0299469,301.9873788,202.0068077,507.6894432,157.6772267,334.3768422,135.0554174,214.2630912,1330.862763,541.0461746,307.033508,0.0
23
+ 2022-07-24,1,776.477908,825.4595302,271.5249881,194.6964057,619.1057667,260.0666358,322.2761157,125.3193069,206.5089226,1452.799799,521.4663146,295.9223064,0.0
24
+ 2022-07-31,1,785.3267172,962.6372069,345.4081407,224.2156499,238.5261414,274.3828509,371.1385861,101.5508396,237.8202057,1251.893504,603.1063041,340.7890968,0.0
25
+ 2022-08-07,1,986.8501755,1025.938955,422.6665647,235.7866071,209.0412688,410.6777854,390.2917036,119.4059165,250.1011998,1417.025462,634.6816576,358.3759871,0.0
26
+ 2022-08-14,1,1006.21652,1142.638552,486.4307695,261.8529063,192.5468754,340.7100759,433.4386,135.4558489,277.7534112,1605.035096,704.8459564,397.9945889,103.920732
27
+ 2022-08-21,1,1045.876273,1071.63155,428.4331739,246.2402262,154.138197,297.8833874,407.5953191,106.1105392,261.1953233,1440.538398,662.8203223,374.2646167,109.3511473
28
+ 2022-08-28,1,924.8436782,982.0672117,380.9582995,222.7309308,62.13676538,205.2154934,368.6809675,108.0664987,236.2580181,2029.075506,595.3198181,338.5324475,109.4662867
29
+ 2022-09-04,1,904.0255621,940.8469486,375.9460785,211.9111493,622.9329915,322.1537139,350.7712524,114.4929439,224.7751952,1238.898241,561.0313292,322.0872816,96.31021073
30
+ 2022-09-11,1,774.0487128,958.7032872,367.374283,216.6169201,911.1160082,304.1690603,358.5605977,102.2195552,229.7675513,1270.879978,573.489781,329.2396609,44.65132361
31
+ 2022-09-18,1,764.4287881,975.7007039,410.3422984,220.4645506,714.4632252,582.8133759,364.9294848,94.58256909,233.8420917,1181.854654,583.6763205,335.0877386,18.13472182
32
+ 2022-09-25,1,923.7236418,960.6266038,331.1681887,217.0223981,717.9420235,414.3210787,359.2317754,77.51748351,230.1648921,1084.965103,596.039424,329.8559537,6.750685498
33
+ 2022-10-02,1,882.1976889,905.1478389,277.5831914,205.8992085,219.2100648,653.009739,340.8198365,79.39525999,218.36179,1299.117345,682.3431097,312.9496328,2.372080109
34
+ 2022-10-09,1,925.6915886,937.4895649,271.0318506,214.0389525,175.4585553,278.0199444,354.2933522,75.45880964,227.0165089,988.3326224,709.3179502,325.3213651,0.906191227
35
+ 2022-10-16,1,959.015952,941.7629421,258.9467906,221.7055116,177.3128816,249.2487123,366.9836166,82.21692268,235.1651607,921.5401156,734.7246713,336.9738958,0.343961469
36
+ 2022-10-23,1,930.856466,920.413168,222.6284273,215.216801,146.6142957,236.4479192,356.2430154,101.3337553,228.2855523,1082.155704,713.2213007,327.1115966,0.122224575
37
+ 2022-10-30,1,875.7574588,870.6189769,283.5774898,208.1475282,100.8371491,298.5716442,344.541424,79.49592653,220.7864015,960.6661455,587.678263,316.3668912,0.043254893
38
+ 2022-11-06,1,803.6846058,783.0789848,281.3661876,197.9310933,176.2377577,304.2184505,327.6304136,68.92122227,209.9334426,1108.999284,518.1268808,300.8387619,0.015048678
39
+ 2022-11-13,1,647.9625567,770.970499,272.4051279,196.0453894,157.6398366,397.0884418,324.5090549,61.72397847,207.9374168,1290.391574,513.1906484,297.9726492,0.005453042
40
+ 2022-11-20,1,410.51923,875.5737551,287.1069279,230.3808944,45.10005665,312.228454,381.3437619,51.98679658,244.3474116,792.170016,603.0711608,350.1597544,0.002344328
41
+ 2022-11-27,1,515.4365373,871.8631846,348.7779578,224.0776323,67.21391461,251.8782636,370.910129,50.54907139,237.6791529,743.5466564,535.9685021,340.5793215,0.000834175
42
+ 2022-12-04,1,775.9431065,751.9638968,317.0579992,199.2553527,76.69204679,291.5840329,329.8224272,34.05423057,211.3571157,873.0841132,413.9884868,302.8515258,0.000271365
43
+ 2022-12-11,1,709.4923926,717.6125648,297.7512423,186.0748608,149.878576,285.1416859,308.0050869,27.63572864,197.3693186,1228.057409,386.6036669,282.8182768,9.27e-05
44
+ 2022-12-18,1,756.3419366,722.0103794,287.4807103,189.5386168,134.5352621,220.7993168,313.738556,38.40880097,200.852912,1514.734677,393.8002369,288.0828972,3.45e-05
45
+ 2022-12-25,1,921.0774008,925.2288971,355.9887642,218.1475832,301.3272623,337.3294677,361.0942662,84.56738121,230.6153342,1892.842275,453.2404604,331.5661412,1.45e-05
46
+ 2023-01-01,1,941.8367772,960.9193838,366.8490383,217.6573364,593.495164,303.9119076,360.2827729,134.6944234,230.8385562,2236.397692,772.0546998,330.821007,70.35472737
47
+ 2023-01-08,1,954.6035992,988.370554,396.9060203,220.6044148,459.1720798,336.3753656,365.1609984,121.7401462,234.0029461,1867.924583,782.5083143,335.3003204,85.80654375
48
+ 2023-01-15,1,996.848517,1036.093236,409.8730378,230.3670254,384.7798026,396.3042818,381.3208049,128.4545641,244.3589615,1781.92823,817.1373766,350.1386748,94.62078669
49
+ 2023-01-22,1,907.6599112,944.9691158,346.3453952,209.7559482,250.1273413,513.5127134,347.2038016,130.5022088,222.4961142,1511.331964,744.0276007,318.8115555,84.09824673
50
+ 2023-01-29,1,774.3921141,800.7599363,284.0726168,178.9583884,259.7907908,402.1916991,296.2253672,89.92870532,189.8279431,1356.106132,566.1600024,272.0018314,57.09380571
51
+ 2023-02-05,1,738.2279086,756.6310299,273.7329359,170.6042753,249.3785662,381.535779,282.3970118,63.15497073,180.9661297,1281.839882,488.5086031,259.3042766,22.92877821
52
+ 2023-02-12,1,806.3032314,823.2695123,290.3194022,186.5988167,193.7645359,354.3389573,308.8723781,46.00288315,197.9323395,1141.09809,534.3074029,283.6146461,9.694651036
53
+ 2023-02-19,1,811.9837253,847.926579,288.9377253,192.5718806,148.356776,327.361602,318.7594422,42.54824661,204.2684901,1112.283767,551.4106852,292.6932053,3.736745996
54
+ 2023-02-26,1,841.0340117,874.3566114,268.0186306,200.5740943,215.6890987,365.3412053,332.0053074,45.39907457,212.7567766,1219.472684,558.0137595,304.8559031,1.434771732
55
+ 2023-03-05,1,855.428122,865.155276,254.0903056,200.9145857,157.8896583,371.8603531,332.5689143,47.57359868,213.1179496,1204.589183,546.5852641,305.3733122,0.527259313
56
+ 2023-03-12,1,787.9587837,836.3060115,234.3598207,195.2757268,157.6073414,373.3335881,323.2350515,40.47258073,207.136592,1284.306192,531.244829,296.8017638,0.187669152
57
+ 2023-03-19,1,709.4342034,817.521727,217.9477557,192.0499114,169.4410563,356.1987464,317.8954395,43.24769286,203.7148436,1242.126802,522.4690441,291.877999,0.067547188
58
+ 2023-03-26,1,688.4936049,766.7113114,167.9836758,184.2114826,194.3286576,292.2202432,304.9206833,44.33831994,195.4003159,1087.191512,496.772508,279.9806566,0.023705804
59
+ 2023-04-02,1,648.4127851,709.374272,379.7574522,172.9962403,123.0072906,296.386829,286.3563718,25.01102175,183.5038702,1109.919508,441.5925556,262.9361771,0.008144821
60
+ 2023-04-09,1,636.8844453,636.0402807,370.8363713,154.8687069,375.6187651,277.765361,256.3503169,19.63808085,164.2752875,977.430835,395.3199674,235.3690974,0.002667482
61
+ 2023-04-16,1,643.202747,697.9311949,400.1671801,169.0921007,303.9842128,288.5176945,279.8939469,26.0160255,179.362597,999.7052811,431.6267961,256.9079406,0.001065489
62
+ 2023-04-23,1,680.2328465,768.0223303,428.1466005,185.2406354,369.5169101,285.729516,306.6242236,25.94739503,196.4919844,1082.094568,472.8477793,280.8264039,0.00042702
63
+ 2023-04-30,1,757.8051683,805.1918653,568.5505022,191.6262435,177.0239561,342.9543489,317.194154,25.48726963,203.2654434,1077.23059,519.6833732,291.2532891,76.08094879
64
+ 2023-05-07,1,816.8896164,809.7824501,623.0873893,193.3403495,132.8104708,432.388876,320.0314696,25.5940547,205.0836617,1114.644548,529.3989259,293.8598601,65.16989915
65
+ 2023-05-14,1,846.3276207,871.5314255,650.3059216,206.9104899,120.1442642,284.4808969,342.4937854,26.57100509,219.4780398,1124.917313,566.5562901,314.4755735,42.71769839
66
+ 2023-05-21,1,742.3856418,860.1913668,534.25428,204.0773489,76.52708573,250.7751673,337.8041576,33.16461757,216.4728164,1153.774175,558.7986658,309.9620644,39.4479893
67
+ 2023-05-28,1,685.9715645,854.9860127,419.3190634,211.2394701,56.89628875,237.4167674,349.6594386,30.06195147,224.0699582,1257.584361,574.2115765,320.9980289,40.58729967
68
+ 2023-06-04,1,659.741062,815.6101963,262.1682047,200.0668991,127.797631,483.0461649,331.1657597,27.1864638,212.2187756,1081.350495,538.5222072,304.0791733,38.42146311
69
+ 2023-06-11,1,626.4784725,774.5792218,209.65455,191.0967281,148.6190586,460.9364201,316.317659,28.18699555,202.7037649,1048.60873,514.3771024,290.4383861,36.6973037
70
+ 2023-06-18,1,638.0935884,776.2166825,193.4182543,192.1920365,148.6214006,430.1358818,318.1306957,23.94794524,203.8656012,867.7902211,517.3253556,292.0209331,36.90751782
71
+ 2023-06-25,1,615.7519552,779.0937361,175.7288582,188.932373,174.7887979,341.5503578,312.7350559,24.54955316,200.4079488,836.245072,514.770607,286.9062403,36.28153974
72
+ 2023-07-02,1,621.2794795,764.9240996,174.1094132,194.5021389,325.8319993,471.0434465,321.9545507,36.67334949,206.3160171,785.0143666,567.758123,295.5412035,37.35112627
73
+ 2023-07-09,1,580.9318638,760.7512215,160.1609936,189.3726234,286.0264842,556.4721175,313.4637914,34.28548491,200.8749396,985.469408,552.7848992,287.6860648,36.36608213
74
+ 2023-07-16,1,691.0363912,729.0096528,172.3823025,170.2445186,337.2839681,652.624446,281.8015154,25.51385772,180.5850116,1625.024876,496.9493337,258.4400254,32.69282556
75
+ 2023-07-23,1,687.8649333,893.0019017,244.0713041,203.3442754,372.0055376,527.8809181,336.5907193,34.34863145,215.6952167,1592.53979,593.5686097,307.4307526,39.0491217
76
+ 2023-07-30,1,543.4952059,925.5413754,306.0685377,210.6151761,546.8054746,544.1495942,348.6260603,31.05021476,223.4077451,1544.034657,628.1932532,320.1174898,40.44538568
77
+ 2023-08-06,1,621.9390612,969.2205314,326.5280836,221.6818558,519.0192833,226.46071,366.9444598,35.7977093,235.1466046,1757.373196,666.8102041,336.937941,42.57057027
78
+ 2023-08-13,1,628.9128166,1014.287182,326.0213373,231.8445167,602.0250578,230.9748621,383.7664595,41.77518663,245.926536,1682.047707,697.3790839,352.3843384,100.8056128
79
+ 2023-08-20,1,335.2835947,967.1172924,311.8617942,221.3894094,400.6572593,138.0241161,366.4603804,47.34643425,234.8363952,2270.35583,665.9305368,336.4934467,119.951625
80
+ 2023-08-27,1,516.0096306,1052.901423,291.3082569,239.4361589,385.581239,133.5620316,396.3327159,42.79171664,253.9792874,1760.723528,680.3115125,363.9228016,132.6774217
81
+ 2023-09-03,1,425.218926,907.3804626,232.4505875,204.0199436,241.6556935,95.21978422,337.709136,23.15806633,216.4119243,2604.193939,491.0303535,310.0921179,100.0283307
82
+ 2023-09-10,1,548.9105155,831.4659197,253.1288112,186.4398897,168.5357607,96.55435719,308.6093103,16.30543897,197.7640744,2650.370027,448.7190973,283.371267,42.36547919
83
+ 2023-09-17,1,446.710714,780.6749097,237.2757502,175.0754168,132.8388084,150.8661646,289.797981,12.31574625,185.709334,2874.469183,421.3673538,266.0610285,16.03044292
84
+ 2023-09-24,1,560.6133792,920.1635269,244.8992536,209.1039271,131.297661,207.1889954,346.1245273,12.7478761,221.8047042,1705.547661,503.2663639,317.8205296,7.268312037
85
+ 2023-10-01,1,678.3406906,944.4331704,226.8916795,217.8674745,94.41199605,185.0175423,360.6306093,7.842450148,231.1005413,1791.039282,497.2463016,331.1403988,2.808861543
86
+ 2023-10-08,1,763.9269378,906.1479737,207.8916876,211.168603,92.25577093,191.036741,349.542134,6.773499719,223.9947866,1500.683497,481.9572407,320.9586728,1.001048031
87
+ 2023-10-15,1,814.021625,867.0010643,193.496147,203.0211766,74.29807486,181.8273082,336.0559018,7.487252365,215.3524932,1595.030622,463.3620941,308.5752506,83.28439757
88
+ 2023-10-22,1,887.494946,890.435337,194.4830652,210.1274647,67.4865255,162.9667114,347.8187636,8.764300735,222.8904105,1777.06454,479.5810155,319.3751355,58.98317443
89
+ 2023-10-29,1,981.0546288,932.5152103,284.8555313,227.94298,90.0912389,190.2309151,377.3083429,8.880990517,241.7880237,1088.380818,479.6898561,346.4543277,26.44608201
90
+ 2023-11-05,1,943.6225993,880.2052338,283.417584,218.2384532,73.76391771,189.9813722,361.2446811,8.617717067,231.4940529,773.8454245,429.3467486,331.7042561,9.711508801
91
+ 2023-11-12,1,859.9426368,784.7082927,268.7375762,198.7428744,52.96298974,155.7534535,328.9741347,8.086477292,210.8143309,843.1577668,390.992539,302.0726015,3.293174362
92
+ 2023-11-19,1,841.5834198,761.789057,267.9687151,194.4867235,47.90933731,136.5205807,321.929034,6.759498821,206.2996654,655.4502986,382.6192916,295.6036069,1.18667682
93
+ 2023-11-26,1,810.4858422,750.223927,218.9064763,187.2994981,38.94589943,119.5074091,310.0321989,4.790676071,198.6758948,934.3953915,374.4267708,284.6796236,0.419087036
94
+ 2023-12-03,1,794.1794746,739.8412707,197.3078416,183.5311519,59.25797091,138.3346547,303.7945489,4.317132205,194.6786626,999.79707,381.3186586,278.9520513,0.150363814
95
+ 2023-12-10,1,799.0346099,751.2994538,185.4197449,184.6531506,39.08780584,133.8354685,305.6517654,4.522006415,195.8688104,932.1781895,383.6498107,280.6566165,0.055362369
96
+ 2023-12-17,1,740.9191363,707.0078691,165.898516,171.2229372,30.97593247,126.4293179,283.4210673,4.152010161,181.6228584,1382.04466,355.7461502,260.2234982,0.018782607
97
+ 2023-12-24,1,771.1616752,794.0299265,166.834395,178.2118461,52.33955324,190.8943106,294.9896343,16.1961226,189.0362671,1377.89555,370.2668533,270.7619601,61.54687964
98
+ 2023-12-31,1,902.4842186,944.0734789,342.6691304,208.5598699,74.90915424,268.009429,345.223963,49.28293154,221.2276015,1673.222589,436.4837233,316.9936163,86.29973693
99
+ 2024-01-07,1,886.1177399,925.4876581,399.2989247,204.7776534,100.4824572,253.4924168,338.9633542,57.15484452,217.2156567,2438.813385,429.0850088,311.2449625,93.51421135
100
+ 2024-01-14,1,930.9929903,975.8722935,418.1218049,215.1481133,92.07061249,317.3728997,356.1293184,58.26787291,228.2160087,2356.367813,450.8149622,327.0071971,101.2048688
101
+ 2024-01-21,1,944.7091262,991.9503913,404.4381143,218.317848,97.06020522,285.3321032,361.3761013,63.32363006,231.5782701,2132.63934,457.45673,331.8249295,80.39592249
102
+ 2024-01-28,1,756.8327128,796.77418,291.755412,174.900493,62.45330919,183.3266773,289.5084339,34.6330342,185.5237855,2403.826128,374.5639516,265.8341692,62.15022457
103
+ 2024-02-04,1,678.2223822,706.1173784,247.9555963,156.7341714,48.12657472,123.9688776,259.4381739,13.7724102,166.2540585,1910.152171,345.2289379,238.2228749,23.90546722
104
+ 2024-02-11,1,698.2864765,717.9268176,249.9909147,161.4955493,45.71740336,113.8285012,267.3195642,13.13273961,171.304638,1352.231509,355.7165388,245.4597723,9.597072979
105
+ 2024-02-18,1,697.868311,716.6343822,263.1942582,161.5547736,41.50723114,112.8980681,267.4175967,12.93070055,171.3674596,1243.833141,355.8469885,245.5497883,3.596622212
Test/scenario_test_df.csv CHANGED
@@ -1,29 +1,105 @@
1
  other_contributions,correction,sales
2
- 5600,246887.59906459102,34624.53421540899
3
- 5600,-6587.690690569492,34228.78454434949
4
- 5600,-11125.741906724448,34987.95213450445
5
- 5600,-12333.285469339673,34245.538462669676
6
- 5600,-15454.13060463002,34770.93366012002
7
- 5600,-11721.21036522913,34621.05417469913
8
- 5600,-12398.918045602568,34555.85506057257
9
- 5600,-13871.185720803369,34751.86235879337
10
- 5600,-11582.460698318933,34443.607438778934
11
- 5600,-12611.146689914676,34909.906400114676
12
- 5600,-13224.948018349281,34749.20428372928
13
- 5600,-14814.523763463389,35982.23456991339
14
- 5600,-12493.777743418319,36231.99397351832
15
- 5600,-12265.065878852936,36233.448789432936
16
- 5600,-11848.693968417523,36230.29543726752
17
- 5600,-7113.326529631435,36281.15143156143
18
- 5600,-7920.372735107798,36941.0092224078
19
- 5600,-4180.405610882663,34707.73902478266
20
- 5600,-953.1776901231351,30146.274477423143
21
- 5600,-4408.892280309261,27987.412376009263
22
- 5600,-4881.939339917117,28474.485593017118
23
- 5600,-2965.1020594815673,27574.204566481567
24
- 5600,-404.74328287227036,26439.255384972268
25
- 5600,-1856.84612884112,26245.779351941124
26
- 5600,-3269.0560383356787,23484.60471123568
27
- 5600,-10218.639212647315,27972.229350047317
28
- 5600,-12574.89665715006,30091.873246450057
29
- 5600,-11702.685508423277,30639.32568624327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  other_contributions,correction,sales
2
+ 1,-890.9055232498959,5690.215291329897
3
+ 1,-475.0356019617411,5552.569481951741
4
+ 1,-3.00287817595472,5560.937947025955
5
+ 1,-55.829572742877644,5425.276077702878
6
+ 1,-556.3358600433276,5516.622888953328
7
+ 1,-798.7245613107443,5445.734322760744
8
+ 1,-831.8611492327145,5200.4203591827145
9
+ 1,-747.1938992814639,5374.298281511465
10
+ 1,-420.2614104889435,5332.908506848943
11
+ 1,-271.18086799521916,5319.33644050522
12
+ 1,36.6270155654438,5391.419920178556
13
+ 1,301.4085809620319,5389.606241371967
14
+ 1,-149.43166229152484,5242.933117331525
15
+ 1,-178.17673782930524,5131.540425919305
16
+ 1,-344.30626848812244,5289.832456958123
17
+ 1,-230.84616606967302,5451.789357969673
18
+ 1,123.82694453031854,5218.370064619681
19
+ 1,-346.3661539520863,5376.024536872087
20
+ 1,-271.2205205272967,5328.849271847297
21
+ 1,-354.5506721690217,5403.073767559021
22
+ 1,-19.423141318857233,5485.366208318857
23
+ 1,280.920011700925,5590.703987999074
24
+ 1,219.92772004464132,5516.867523255358
25
+ 1,781.0340386556309,5679.80924444437
26
+ 1,1294.215508564199,5794.624423935802
27
+ 1,738.5041899802227,5867.574283419777
28
+ 1,796.9530305592698,5766.398891020729
29
+ 1,415.4269541484191,5870.755943781581
30
+ 1,786.9040839666868,5653.932635343313
31
+ 1,699.8256250848854,5780.4948975251145
32
+ 1,539.7466595910291,5709.582592216971
33
+ 1,377.1020126805497,5701.30477291845
34
+ 1,-171.62474653670506,5654.002002503705
35
+ 1,2.5849602971611603,5483.356174051838
36
+ 1,-34.222062215807455,5514.872288290807
37
+ 1,-232.94749697125917,5380.036050594259
38
+ 1,-468.2098834663175,5549.1920170143185
39
+ 1,-322.55244907838915,5460.395075290389
40
+ 1,-286.06762659350443,4870.058190251504
41
+ 1,-567.8472905522367,5126.328448227237
42
+ 1,-178.17983426540468,4755.834439790405
43
+ 1,-138.01821631918847,4914.4591182591885
44
+ 1,-224.74716002627974,5285.071496596279
45
+ 1,792.8650476428393,5620.160200367161
46
+ 1,1355.630591283547,6164.482894686454
47
+ 1,986.2819407849784,6162.193945065021
48
+ 1,1059.4585386492327,6192.766760540768
49
+ 1,383.3271727567453,6147.514743873256
50
+ 1,-187.89305181649252,5715.402384446493
51
+ 1,-212.6188366426577,5361.828983682658
52
+ 1,72.73991611608744,5103.376930469912
53
+ 1,-95.72047604730415,5238.559346653305
54
+ 1,-120.65966666702116,5559.61159556902
55
+ 1,-129.04437521984528,5484.718157112846
56
+ 1,-225.8057201453703,5494.031670527371
57
+ 1,-218.36269867398096,5302.355467121982
58
+ 1,-527.1081401204074,5229.684817164407
59
+ 1,-787.2316784692694,5426.49419694027
60
+ 1,-1039.0670757847201,5539.46725861672
61
+ 1,-753.3438144522797,5429.75259714128
62
+ 1,-357.58568725637724,5439.307307306376
63
+ 1,-324.8889333863972,5678.236085806397
64
+ 1,-133.49090182590044,5695.572473075901
65
+ 1,-45.99030825180944,5662.900632331809
66
+ 1,-198.89465585490962,5516.530032454908
67
+ 1,-140.8356983902304,5403.83747958023
68
+ 1,-328.0646448624011,5409.439140572401
69
+ 1,-471.0425565209507,5319.73694927095
70
+ 1,-340.95558014868584,4979.621694008686
71
+ 1,-451.51062198216823,4939.252717082169
72
+ 1,-470.36961068723394,5272.668924347234
73
+ 1,-241.20706862409952,5185.8530426641
74
+ 1,208.85641111961377,5444.732313460386
75
+ 1,515.8119847274293,5531.57972692257
76
+ 1,645.0697458315044,5567.480423908495
77
+ 1,600.0430036810403,5726.387206688959
78
+ 1,991.7181579008802,5546.43253882912
79
+ 1,1013.1553381743997,5402.552776275601
80
+ 1,917.9547927897802,5331.5829309502205
81
+ 1,1015.0301292769545,5173.539135873046
82
+ 1,696.1730710283628,5336.366877121637
83
+ 1,847.2383603827184,5141.954472787283
84
+ 1,306.9976047314858,5080.849112605514
85
+ 1,584.0224670446787,4984.748530996321
86
+ 1,320.83510529009254,4936.503487589907
87
+ 1,90.36675074638242,5252.446656848617
88
+ 1,403.12179948645917,5224.349590578541
89
+ 1,83.756178874728,5191.882766452272
90
+ 1,-278.2221225414887,5013.415671819488
91
+ 1,-594.5830415220298,5002.82188941603
92
+ 1,-638.5622841161676,4758.668189667168
93
+ 1,-820.1475431582649,5052.9362379952645
94
+ 1,-777.5132874651554,5052.974139294155
95
+ 1,-937.336274112341,5133.249068936341
96
+ 1,-766.0661090095928,5175.7488448475915
97
+ 1,-601.9630042407716,5336.127977920771
98
+ 1,-43.382722961047875,5912.822165571049
99
+ 1,783.5552448429935,5872.093028327005
100
+ 1,1048.3411480573423,5779.245607242658
101
+ 1,942.7173296927785,5657.685381977221
102
+ 1,459.91919626775507,5422.163314992245
103
+ 1,-457.09347441516366,5375.192548655164
104
+ 1,-547.8506448682429,4949.858142417243
105
+ 1,-1007.0054924523847,5301.204813554385
__pycache__/classes.cpython-39.pyc ADDED
Binary file (11.3 kB). View file
 
__pycache__/utilities.cpython-39.pyc ADDED
Binary file (15.5 kB). View file
 
__pycache__/utilities_with_panel.cpython-39.pyc ADDED
Binary file (20.9 kB). View file
 
classes.py CHANGED
@@ -275,6 +275,7 @@ class Scenario:
275
  # return zip(channels_list, res.x)
276
 
277
  def optimize_spends(self, sales_percent, channels_list, algo="trust-constr"):
 
278
  desired_sales = self.actual_total_sales * (1 + sales_percent / 100.0)
279
 
280
  def constraint(x):
@@ -285,7 +286,7 @@ class Scenario:
285
  bounds = []
286
  for ch in channels_list:
287
  bounds.append(
288
- (1 + np.array([-50.0, 100.0]) / 100.0)
289
  * self.channels[ch].actual_total_spends
290
  )
291
 
@@ -303,7 +304,7 @@ class Scenario:
303
  x0=initial_point,
304
  constraints=constraints,
305
  method=algo,
306
- options={"maxiter": int(2e7), "xtol": 100},
307
  )
308
 
309
  for channel_name, modified_spends in zip(channels_list, res.x):
@@ -339,20 +340,22 @@ class Scenario:
339
  (1 + spends_percent / 100)
340
  )
341
  old_spends.append(channel_actual_total_spends)
342
- bounds.append((1 + channel_bounds / 100) * channel_actual_total_spends)
343
 
344
  def objective_function(x):
345
  for channel_name, modified_spends in zip(channels_list, x):
346
  self.update(channel_name, modified_spends)
347
  return -1 * self.modified_total_sales
348
 
 
 
349
  res = minimize(
350
- lambda x: objective_function(x) / 1e8,
351
  method="trust-constr",
352
  x0=old_spends,
353
  constraints=constraint,
354
  bounds=bounds,
355
- options={"maxiter": int(1e7), "xtol": 100},
356
  )
357
  # res = dual_annealing(
358
  # objective_function,
 
275
  # return zip(channels_list, res.x)
276
 
277
  def optimize_spends(self, sales_percent, channels_list, algo="trust-constr"):
278
+ print("%"*100)
279
  desired_sales = self.actual_total_sales * (1 + sales_percent / 100.0)
280
 
281
  def constraint(x):
 
286
  bounds = []
287
  for ch in channels_list:
288
  bounds.append(
289
+ (1+np.array([-50.0, 100.0]) / 100.0)
290
  * self.channels[ch].actual_total_spends
291
  )
292
 
 
304
  x0=initial_point,
305
  constraints=constraints,
306
  method=algo,
307
+ options={"maxiter": int(2e7), "xtol": 10},
308
  )
309
 
310
  for channel_name, modified_spends in zip(channels_list, res.x):
 
340
  (1 + spends_percent / 100)
341
  )
342
  old_spends.append(channel_actual_total_spends)
343
+ bounds.append((1+ channel_bounds / 100) * channel_actual_total_spends)
344
 
345
  def objective_function(x):
346
  for channel_name, modified_spends in zip(channels_list, x):
347
  self.update(channel_name, modified_spends)
348
  return -1 * self.modified_total_sales
349
 
350
+ print(bounds)
351
+ print("$"*100)
352
  res = minimize(
353
+ lambda x: objective_function(x) / 1e3,
354
  method="trust-constr",
355
  x0=old_spends,
356
  constraints=constraint,
357
  bounds=bounds,
358
+ options={"maxiter": int(1e7), "xtol": 50},
359
  )
360
  # res = dual_annealing(
361
  # objective_function,
summary_df.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e87645c85f167c009e00eae80fbe54392be6fb73096f5959d7b108c00aa72708
3
- size 1233
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1b0b3954664cb2e6a7ed10e74ff599cc25479153bb9ee953a602ce03710de55
3
+ size 2269
utilities.py CHANGED
@@ -39,7 +39,7 @@ color_palette = [
39
  ]
40
 
41
 
42
- CURRENCY_INDICATOR = '€'
43
 
44
  import streamlit_authenticator as stauth
45
 
@@ -206,7 +206,7 @@ def panel_level(input_df, date_column="Date"):
206
 
207
 
208
  def initialize_data(
209
- panel=None, target_file="Overview_data_test_panel@#revenue.xlsx", updated_rcs=None, metrics=None
210
  ):
211
  # uopx_conv_rates = {'streaming_impressions' : 0.007,'digital_impressions' : 0.007,'search_clicks' : 0.00719,'tv_impressions' : 0.000173,
212
  # "digital_clicks":0.005,"streaming_clicks":0.004,'streaming_spends':1,"tv_spends":1,"search_spends":1,
 
39
  ]
40
 
41
 
42
+ CURRENCY_INDICATOR = '$'
43
 
44
  import streamlit_authenticator as stauth
45
 
 
206
 
207
 
208
  def initialize_data(
209
+ panel=None, target_file="Overview_data_test_panel@#prospects.xlsx", updated_rcs=None, metrics=None
210
  ):
211
  # uopx_conv_rates = {'streaming_impressions' : 0.007,'digital_impressions' : 0.007,'search_clicks' : 0.00719,'tv_impressions' : 0.000173,
212
  # "digital_clicks":0.005,"streaming_clicks":0.004,'streaming_spends':1,"tv_spends":1,"search_spends":1,