Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import joblib
|
2 |
+
import pandas as pd
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
model = joblib.load('model_a.joblib')
|
8 |
+
unique_values = unique_values = joblib.load('unique_values.joblib')
|
9 |
+
|
10 |
+
unique_store_city = unique_values["store_city"]
|
11 |
+
unique_promotion_name= unique_values["promotion_name"]
|
12 |
+
unique_media_type = unique_values["media_type"]
|
13 |
+
unique_store_type = unique_values["store_type"]
|
14 |
+
unique_sales_country= unique_values["sales_country"]
|
15 |
+
unique_store_state = unique_values["store_state"]
|
16 |
+
|
17 |
+
def main():
|
18 |
+
st.title("Adult Income")
|
19 |
+
|
20 |
+
with st.form("questionaire"):
|
21 |
+
store_sqft = st.slider('store_sqft',min_value=10,max_value=100)
|
22 |
+
store_city = st.selectbox('store_city',options=unique_store_city)
|
23 |
+
promotion_name = st.selectbox('promotion_name',options=unique_promotion_name)
|
24 |
+
media_type = st.selectbox('media_type ',options=unique_media_type)
|
25 |
+
store_type = st.selectbox('Occupation',options=unique_store_type)
|
26 |
+
sales_country = st.selectbox('Relationship',options=sales_country)
|
27 |
+
store_state = st.selectbox('sales_country',options=unique_store_state)
|
28 |
+
meat_sqft = st.slider('meat_sqft',min_value=1,max_value=100)
|
29 |
+
frozen_sqft = st.slider('frozen_sqft',min_value=1,max_value=100)
|
30 |
+
|
31 |
+
# clicked==True only when the button is clicked
|
32 |
+
clicked = st.form_submit_button("Predict income")
|
33 |
+
if clicked:
|
34 |
+
result=model.predict(pd.DataFrame({"store_sqft": [store_sqft],
|
35 |
+
"store_city": [store_city],
|
36 |
+
"promotion_name": [promotion_name],
|
37 |
+
"media_type": [media_type],
|
38 |
+
"store_type ": [store_type ],
|
39 |
+
"sales_country": [sales_country],
|
40 |
+
"store_state": [store_state],
|
41 |
+
"meat_sqft": [meat_sqft],
|
42 |
+
"frozen_sqft": [frozen_sqft]}))
|
43 |
+
|
44 |
+
# Show prediction
|
45 |
+
|
46 |
+
st.success('Your Predicted income is' + result)
|
47 |
+
# Run main()
|
48 |
+
if __name__ == "__main__":
|
49 |
+
main()
|