import streamlit as st
import joblib
import pandas as pd
from scipy.stats import yeojohnson
import inv_transform
# Title of the app
st.title("Event Budget Estimate")
# Add custom CSS for spacing between columns
st.markdown(
"""
""", unsafe_allow_html=True)
# Create columns with adjusted spacing
col1, col2 = st.columns([1, 1], gap="large") # Adjust gap as needed
with col1:
# Smaller column title
#st.subheader("Event Data")
st.markdown("### Event Data")
# Input fields
atnd_num = st.number_input("Estimate Number of Attendees", min_value=0, value=180)
ppr_num = st.number_input("Estimate Paper Number", min_value=0, value=100)
exh_num = st.number_input("Estimate Number of Exhibits", min_value=0, value=0)
long = st.number_input("Conference Duration, Days", min_value=0, value=3)
# Dropdown menus
event_type = st.selectbox("Event Type", ["Conference", "Workshop", "Forum", "Other"])
cntry = st.selectbox("Conference Location Country", ["USA", "China", "India", "Romania", "Other"])
if cntry =="USA":
loc_state = st.selectbox("Conference Location State", [ "CA", "NJ", "NY", "FL", "Other"], index=4)
else:
loc_state = "Other"
# Checkboxes
st.markdown("
Keywords
", unsafe_allow_html=True)
kw_comp = st.checkbox("Computing")
kw_sys = st.checkbox("Systems")
kw_app = st.checkbox("Applications")
kw_computational = st.checkbox("Computational")
kw_wless = st.checkbox("Wireless")
kw_mdl = st.checkbox("Modeling")
kw_ntwk = st.checkbox("Networking")
kw_des = st.checkbox("Design")
kw_adv = st.checkbox("Advanced")
kw_dist = st.checkbox("Distributed")
submit = st.button("Submit")
# If the submit button is clicked, show output in the second column (col2)
with col2:
if submit:
if cntry != "USA" and loc_state != "Other":
st.error("Correct Event Location: Country and State!")
else:
try:
p = True
regressor = joblib.load("budget_prediction_model.joblib")
except:
p = False
if not p:
st.write('Check the model path')
st.error("Model doesn't Exist!")
else:
atnd_num = atnd_num / 1.1
ppr_num = ppr_num / 1.08
data = pd.DataFrame([{'act_atnd_tot_atnd_num': atnd_num,
'long_atnd_ratio':long/atnd_num,
'act_paprs_num': ppr_num,
'longevity': long,
'papr_atnd_ratio':ppr_num/atnd_num,
'exh_num': exh_num,
'exh_atnd_ratio': exh_num/atnd_num,
'computing': int(kw_comp),
'conf_loc_cntry_nm_USA': int(cntry == "USA"),
'conf_loc_cntry_nm_India': int(cntry == "India"),
'conf_evnt_typ_nm_Workshop': int(event_type == "Workshop"),
'conf_loc_state_nm_CA': int(loc_state == "CA"),
'conf_loc_state_nm_NJ': int(loc_state == "NJ"),
'systems': int(kw_sys),
'applications': int(kw_app),
'computational': int(kw_computational),
'conf_loc_cntry_nm_China': int(cntry == "China"),
'wireless': int(kw_wless),
'conf_loc_cntry_nm_Romania': int(cntry == "Romania"),
'conf_loc_state_nm_FL': int(loc_state == "FL"),
'modeling': int(kw_mdl),
'networking': int(kw_ntwk),
'design': int(kw_des),
'conf_loc_state_nm_NY': int(loc_state == "NY"),
'conf_evnt_typ_nm_Forum': int(event_type == "Forum"),
'advanced': int(kw_adv),
'distributed': int(kw_dist)
}])
lambdas = pd.read_csv('lambdas_yeojohnson.csv', header=None, index_col=0)
lambdas = lambdas.to_dict()[1]
for n in ['act_atnd_tot_atnd_num', 'exh_num', 'act_paprs_num']:
data[n] = yeojohnson(data[n], lambdas[n])
data.longevity -= 1
# Predict income
income = regressor.predict(data)[0]
income = inv_transform.inv_yeojohnson(income, lambdas['fin_inc_tot_amt'])
reg_fees_inc = income * 0.74
exh_inc = min(exh_num * 3000, income - reg_fees_inc)
expenses = income * 0.833
local_arr_exp = expenses * 0.331
socl_funcs_exp = expenses * 0.383
admintn_exp = expenses * 0.091
audit_exp = max(expenses*0.007, 6000)
# Display results
st.markdown("### Predicted Budget*")
st.markdown("Income Structure
", unsafe_allow_html=True)
st.write(f"**Total Income: ${round(round(income, -3))}**")
st.write(f"Registration Fees Income: ${round(round(reg_fees_inc, -3))}")
st.write(f"Exhibit Income: ${round(round(exh_inc, -3))}")
st.markdown("Expenses Structure
", unsafe_allow_html=True)
st.write(f"**Total Expenses: ${round(round(expenses, -3))}**")
st.write(f"Local Arrangement Amount: ${round(round(local_arr_exp, -3))}")
st.write(f"Social Functions Amount: ${round(round(socl_funcs_exp, -3))}")
st.write(f"Administration Amount: ${round(round(admintn_exp, -3))}")
st.write(f"Audit Fees Amount: ${round(round(audit_exp, -3))}")
st.write("")
st.write("***The numbers are approximate and should be adjusted according to event needs**")