rajababu15 commited on
Commit
f62a6e1
1 Parent(s): d808041

created app.py

Browse files
Files changed (1) hide show
  1. app.py +89 -0
app.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import pickle
4
+
5
+ # Load the preprocessor and model from the pickle files
6
+ with open('preprocesor.pkl', 'rb') as file:
7
+ preprocessor = pickle.load(file)
8
+
9
+ with open('model.pkl', 'rb') as file:
10
+ model = pickle.load(file)
11
+
12
+ # Define the app
13
+ def run():
14
+ st.title("Model Testing App")
15
+
16
+ # Create inputs for all features
17
+ Timestamp = st.date_input("Timestamp")
18
+ Age = st.number_input("Age", min_value=0, max_value=100)
19
+ Gender = st.selectbox("Gender", ["Male", "Female", "M"])
20
+ Country = st.text_input("Country")
21
+ state = st.text_input("State")
22
+ self_employed = st.checkbox("Self Employed")
23
+ family_history = st.checkbox("Family History")
24
+ treatment = st.selectbox("Treatment", ["Yes", "No"])
25
+ work_interfere = st.selectbox("Work Interfere", ["Sometimes", "Never", "Often"])
26
+ no_employees = st.selectbox("No. of Employees", ["1-5", "6-25", "26-100", "100-500", "500-1000", "More than 1000"])
27
+ remote_work = st.checkbox("Remote Work")
28
+ tech_company = st.checkbox("Tech Company")
29
+ benefits = st.selectbox("Benefits", ["Yes", "No", "Don't know"])
30
+ care_options = st.selectbox("Care Options", ["Yes", "No", "Not sure"])
31
+ wellness_program = st.selectbox("Wellness Program", ["Yes", "No", "Don't know"])
32
+ seek_help = st.selectbox("Seek Help", ["Yes", "No", "Don't know"])
33
+ anonymity = st.selectbox("Anonymity", ["Yes", "No", "Don't know"])
34
+ leave = st.selectbox("Leave", ["Somewhat easy","Somewhat difficult","Very difficult","Don't know"])
35
+ mental_health_consequence = st.selectbox("Mental Health Consequence", ["Yes","No","Maybe"])
36
+ phys_health_consequence = st.selectbox("Physical Health Consequence", ["Yes","No","Maybe"])
37
+ coworkers = st.selectbox("Coworkers", ["Yes","No","Some of them"])
38
+ supervisor = st.selectbox("Supervisor", ["Yes","No","Some of them"])
39
+ mental_health_interview = st.selectbox("Mental Health Interview", ["Yes","No","Maybe"])
40
+ phys_health_interview = st.selectbox("Physical Health Interview", ["Yes","No","Maybe"])
41
+ mental_vs_physical = st.selectbox("Mental vs Physical", ["Yes","No","Don't know"])
42
+ obs_consequence = st.selectbox("Obs Consequence", ["Yes","No"])
43
+
44
+ # Create a new data point
45
+ new_data = pd.DataFrame({
46
+ "Timestamp": [Timestamp],
47
+ "Age": [Age],
48
+ "Gender": [Gender],
49
+ "Country": [Country],
50
+ "state": [state],
51
+ "self_employed": [self_employed],
52
+ "family_history": [family_history],
53
+ "treatment": [treatment],
54
+ "work_interfere": [work_interfere],
55
+ "no_employees": [no_employees],
56
+ "remote_work": [remote_work],
57
+ "tech_company": [tech_company],
58
+ "benefits": [benefits],
59
+ "care_options": [care_options],
60
+ "wellness_program": [wellness_program],
61
+ "seek_help": [seek_help],
62
+ "anonymity": [anonymity],
63
+ "leave": [leave],
64
+ "mental_health_consequence": [mental_health_consequence],
65
+ "phys_health_consequence": [phys_health_consequence],
66
+ "coworkers": [coworkers],
67
+ "supervisor": [supervisor],
68
+ "mental_health_interview": [mental_health_interview],
69
+ "phys_health_interview": [phys_health_interview],
70
+ "mental_vs_physical": [mental_vs_physical],
71
+ "obs_consequence": [obs_consequence]
72
+ })
73
+
74
+ # Preprocess the new data
75
+ new_data_transformed = preprocessor.transform(new_data.drop(columns=['treatment'],axis=1))
76
+
77
+ # Make a prediction
78
+ prediction = model.predict(new_data_transformed)[0]
79
+
80
+ if st.button('Predict'):
81
+ if prediction == 1:
82
+ result ='Yes'
83
+ st.success('The output is {}'.format(result))
84
+ else:
85
+ result ='No'
86
+ st.success('The output is {}'.format(result))
87
+
88
+ if __name__=='__main__':
89
+ run()