ov-pinka commited on
Commit
2321d93
·
verified ·
1 Parent(s): 5c656e3

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +95 -67
  2. budget_prediction_model.joblib +2 -2
app.py CHANGED
@@ -35,16 +35,25 @@ with col1:
35
  long = st.number_input("Conference Duration, Days", min_value=0, value=3)
36
 
37
  # Dropdown menus
38
- event_type = st.selectbox("Event Type", ["Conference", "Workshop", "Other"])
39
- cntry = st.selectbox("Conference Location Country", ["USA", "China", "India", "Other"])
40
- loc_state = st.selectbox("Conference Location State", ["NJ", "CA", "Other"])
 
 
 
 
41
  # Checkboxes
42
- st.text("Keywords")
43
  kw_comp = st.checkbox("Computing")
44
- kw_edu = st.checkbox("Education")
45
  kw_app = st.checkbox("Applications")
46
  kw_computational = st.checkbox("Computational")
47
- kw_sys = st.checkbox("Systems")
 
 
 
 
 
48
 
49
 
50
  submit = st.button("Submit")
@@ -52,66 +61,85 @@ submit = st.button("Submit")
52
  # If the submit button is clicked, show output in the second column (col2)
53
  with col2:
54
  if submit:
55
- try:
56
- p = True
57
- regressor = joblib.load("budget_prediction_model.joblib")
58
- except:
59
- p = False
60
-
61
- if not p:
62
- st.write('Check the model path')
63
  else:
64
- atnd_num = atnd_num / 1.1
65
- ppr_num = ppr_num / 1.08
66
-
67
-
68
- data = pd.DataFrame([{'act_atnd_tot_atnd_num': atnd_num,
69
- 'long_atnd_ratio':long/atnd_num,
70
- 'act_paprs_num': ppr_num,
71
- 'longevity': long,
72
- 'papr_atnd_ratio':ppr_num/atnd_num,
73
- 'exh_num': exh_num,
74
- 'exh_atnd_ratio': exh_num/atnd_num,
75
- 'conf_loc_cntry_nm_USA': int(cntry == "USA"),
76
- 'computing': int(kw_comp),
77
- 'conf_evnt_typ_nm_Workshop': int(event_type == "Workshop"),
78
- 'conf_loc_state_nm_CA': int(loc_state == "CA"),
79
- 'education': int(kw_edu),
80
- 'applications': int(kw_app),
81
- 'conf_loc_state_nm_NJ': int(loc_state == "NJ"),
82
- 'computational': int(kw_computational),
83
- 'systems': int(kw_sys),
84
- 'conf_loc_cntry_nm_China': int(cntry == "China"),
85
- 'conf_loc_cntry_nm_India': int(cntry == "India")
86
- }])
87
-
88
- lambdas = pd.read_csv('lambdas_yeojohnson.csv', header=None, index_col=0)
89
- lambdas = lambdas.to_dict()[1]
90
-
91
- for n in ['act_atnd_tot_atnd_num', 'exh_num', 'act_paprs_num']:
92
- data[n] = yeojohnson(data[n], lambdas[n])
93
- data.longevity -= 1
94
-
95
- # Predict income
96
- income = regressor.predict(data)[0]
97
- income = inv_transform.inv_yeojohnson(income, lambdas['fin_inc_tot_amt'])
98
-
99
- reg_fees_inc = income * 0.74
100
- exh_inc = min(exh_num * 3000, income - reg_fees_inc)
101
-
102
- expenses = income * 0.833
103
- local_arr_exp = expenses * 0.331
104
- socl_funcs_exp = expenses * 0.383
105
- admintn_exp = expenses * 0.091
106
 
107
- # Display results
108
- st.markdown("### Predicted Budget")
109
- st.markdown("<h4>Income Structure</h4>", unsafe_allow_html=True)
110
- st.write(f"**Total Income: ${round(round(income, -3))}**")
111
- st.write(f"Registration Fees Income: ${round(round(reg_fees_inc, -3))}")
112
- st.write(f"Exhibit Income: ${round(round(exh_inc, -3))}")
113
- st.markdown("<h4>Expenses Structure</h4>", unsafe_allow_html=True)
114
- st.write(f"**Total Expenses: ${round(round(expenses, -3))}**")
115
- st.write(f"Local Arrangement Amount: ${round(round(local_arr_exp, -3))}")
116
- st.write(f"Social Functions Amount: ${round(round(socl_funcs_exp, -3))}")
117
- st.write(f"Administration Amount: ${round(round(admintn_exp, -3))}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  long = st.number_input("Conference Duration, Days", min_value=0, value=3)
36
 
37
  # Dropdown menus
38
+ event_type = st.selectbox("Event Type", ["Conference", "Workshop", "Forum", "Other"])
39
+ cntry = st.selectbox("Conference Location Country", ["USA", "China", "India", "Romania", "Other"])
40
+ if cntry =="USA":
41
+ loc_state = st.selectbox("Conference Location State", [ "CA", "NJ", "NY", "FL", "Other"], index=4)
42
+ else:
43
+ loc_state = "Other"
44
+
45
  # Checkboxes
46
+ st.markdown("<h4>Keywords</h4>", unsafe_allow_html=True)
47
  kw_comp = st.checkbox("Computing")
48
+ kw_sys = st.checkbox("Systems")
49
  kw_app = st.checkbox("Applications")
50
  kw_computational = st.checkbox("Computational")
51
+ kw_wless = st.checkbox("Wireless")
52
+ kw_mdl = st.checkbox("Modeling")
53
+ kw_ntwk = st.checkbox("Networking")
54
+ kw_des = st.checkbox("Design")
55
+ kw_adv = st.checkbox("Advanced")
56
+ kw_dist = st.checkbox("Distributed")
57
 
58
 
59
  submit = st.button("Submit")
 
61
  # If the submit button is clicked, show output in the second column (col2)
62
  with col2:
63
  if submit:
64
+ if cntry != "USA" and loc_state != "Other":
65
+ st.error("Correct Event Location: Country and State!")
 
 
 
 
 
 
66
  else:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
+ try:
69
+ p = True
70
+ regressor = joblib.load("budget_prediction_model.joblib")
71
+ except:
72
+ p = False
73
+
74
+ if not p:
75
+ st.write('Check the model path')
76
+ st.error("Model doesn't Exist!")
77
+ else:
78
+ atnd_num = atnd_num / 1.1
79
+ ppr_num = ppr_num / 1.08
80
+
81
+ data = pd.DataFrame([{'act_atnd_tot_atnd_num': atnd_num,
82
+ 'long_atnd_ratio':long/atnd_num,
83
+ 'act_paprs_num': ppr_num,
84
+ 'longevity': long,
85
+ 'papr_atnd_ratio':ppr_num/atnd_num,
86
+ 'exh_num': exh_num,
87
+ 'exh_atnd_ratio': exh_num/atnd_num,
88
+ 'computing': int(kw_comp),
89
+ 'conf_loc_cntry_nm_USA': int(cntry == "USA"),
90
+ 'conf_loc_cntry_nm_India': int(cntry == "India"),
91
+ 'conf_evnt_typ_nm_Workshop': int(event_type == "Workshop"),
92
+ 'conf_loc_state_nm_CA': int(loc_state == "CA"),
93
+ 'conf_loc_state_nm_NJ': int(loc_state == "NJ"),
94
+ 'systems': int(kw_sys),
95
+ 'applications': int(kw_app),
96
+ 'computational': int(kw_computational),
97
+ 'conf_loc_cntry_nm_China': int(cntry == "China"),
98
+ 'wireless': int(kw_wless),
99
+ 'conf_loc_cntry_nm_Romania': int(cntry == "Romania"),
100
+ 'conf_loc_state_nm_FL': int(loc_state == "FL"),
101
+ 'modeling': int(kw_mdl),
102
+ 'networking': int(kw_ntwk),
103
+ 'design': int(kw_des),
104
+ 'conf_loc_state_nm_NY': int(loc_state == "NY"),
105
+ 'conf_evnt_typ_nm_Forum': int(event_type == "Forum"),
106
+ 'advanced': int(kw_adv),
107
+ 'distributed': int(kw_dist)
108
+
109
+ }])
110
+
111
+
112
+ lambdas = pd.read_csv('lambdas_yeojohnson.csv', header=None, index_col=0)
113
+ lambdas = lambdas.to_dict()[1]
114
+
115
+ for n in ['act_atnd_tot_atnd_num', 'exh_num', 'act_paprs_num']:
116
+ data[n] = yeojohnson(data[n], lambdas[n])
117
+ data.longevity -= 1
118
+
119
+ # Predict income
120
+ income = regressor.predict(data)[0]
121
+ income = inv_transform.inv_yeojohnson(income, lambdas['fin_inc_tot_amt'])
122
+
123
+ reg_fees_inc = income * 0.74
124
+ exh_inc = min(exh_num * 3000, income - reg_fees_inc)
125
+
126
+ expenses = income * 0.833
127
+ local_arr_exp = expenses * 0.331
128
+ socl_funcs_exp = expenses * 0.383
129
+ admintn_exp = expenses * 0.091
130
+ audit_exp = max(expenses*0.007, 6000)
131
+
132
+ # Display results
133
+ st.markdown("### Predicted Budget*")
134
+ st.markdown("<h4>Income Structure</h4>", unsafe_allow_html=True)
135
+ st.write(f"**Total Income: ${round(round(income, -3))}**")
136
+ st.write(f"Registration Fees Income: ${round(round(reg_fees_inc, -3))}")
137
+ st.write(f"Exhibit Income: ${round(round(exh_inc, -3))}")
138
+ st.markdown("<h4>Expenses Structure</h4>", unsafe_allow_html=True)
139
+ st.write(f"**Total Expenses: ${round(round(expenses, -3))}**")
140
+ st.write(f"Local Arrangement Amount: ${round(round(local_arr_exp, -3))}")
141
+ st.write(f"Social Functions Amount: ${round(round(socl_funcs_exp, -3))}")
142
+ st.write(f"Administration Amount: ${round(round(admintn_exp, -3))}")
143
+ st.write(f"Audit Fees Amount: ${round(round(audit_exp, -3))}")
144
+ st.write("")
145
+ st.write("***The numbers are approximate and should be adjusted according to event needs**")
budget_prediction_model.joblib CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f21f28e7ba6a51923a8fa8afd72f6e7182213b6acc399d71d07d4ffc4e668075
3
- size 30783753
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1638cad00656550f71eedb730ffbb33b9fc0b42f23dc6397d975586487c842bb
3
+ size 29676185