Vishnurak commited on
Commit
badf1d7
1 Parent(s): 80fafc0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -51
app.py CHANGED
@@ -1,65 +1,34 @@
1
  import joblib
2
  import pandas as pd
 
3
 
4
 
5
- EDU_DICT = {'Preschool': 1,
6
- '1st-4th': 2,
7
- '5th-6th': 3,
8
- '7th-8th': 4,
9
- '9th': 5,
10
- '10th': 6,
11
- '11th': 7,
12
- '12th': 8,
13
- 'HS-grad': 9,
14
- 'Some-college': 10,
15
- 'Assoc-voc': 11,
16
- 'Assoc-acdm': 12,
17
- 'Bachelors': 13,
18
- 'Masters': 14,
19
- 'Prof-school': 15,
20
- 'Doctorate': 16
21
  }
22
 
23
- model = #
24
- unique_values = #
25
 
26
- unique_class = unique_values["workclass"]
27
- unique_education = unique_values["education"]
28
- unique_marital_status = unique_values["marital.status"]
29
- unique_relationship = unique_values["relationship"]
30
- unique_occupation = unique_values["occupation"]
31
- unique_sex = unique_values["sex"]
32
- unique_race = unique_values["race"]
33
- unique_country = unique_values["native.country"]
34
-
35
  def main():
36
- st.title("Adult Income")
37
 
38
  with st.form("questionaire"):
39
- age = # user's input
40
- workclass = # user's input
41
- education = # user's input
42
- Marital_Status = # user's input
43
- occupation = # user's input
44
- relationship = # user's input
45
- race = # user's input
46
- sex = # user's input
47
- hours_per_week = # user's input
48
- native_country = # user's input
49
 
50
  # clicked==True only when the button is clicked
51
- clicked = st.form_submit_button("Predict income")
52
  if clicked:
53
- result=model.predict(pd.DataFrame({"age": [age],
54
- "workclass": [workclass],
55
- "education": [EDU_DICT[education]],
56
- "marital.status": [Marital_Status],
57
- "occupation": [occupation],
58
- "relationship": [relationship],
59
- "race": [race],
60
- "sex": [sex],
61
- "hours.per.week": [hours_per_week],
62
- "native.country": [native_country]}))
63
  # Show prediction
64
-
65
- # Run main()
 
 
 
1
  import joblib
2
  import pandas as pd
3
+ import streamlit as st
4
 
5
 
6
+ EDU_DICT = {'Iris-setosa': 1,
7
+ 'Iris-versicolor': 2,
8
+ 'Iris-virginica': 3,
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
 
11
+ model = joblib.load('model.joblib')
12
+ unique_values = joblib.load('unique_values.joblib')
13
 
 
 
 
 
 
 
 
 
 
14
  def main():
15
+ st.title("Iris's Class")
16
 
17
  with st.form("questionaire"):
18
+ sepal length = st.slider("Sepal_length", min_value=0, max_value=6)
19
+ sepal width = st.slider("Sepal_width", min_value=0, max_value=6)
20
+ petal length = st.slider("Petal_length", min_value=0, max_value=6)
21
+ petal width = st.slider("Petal_width", min_value=0, max_value=6)
 
 
 
 
 
 
22
 
23
  # clicked==True only when the button is clicked
24
+ clicked = st.form_submit_button("Predict class")
25
  if clicked:
26
+ result=model.predict(pd.DataFrame({"sepal length": [sepal length],
27
+ "sepal width": [sepal width],
28
+ "petal length": [petal length],
29
+ "petal width": [petal width]}))
 
 
 
 
 
 
30
  # Show prediction
31
+ result = "class" : [iris_DICT[class]]
32
+ st.success("Your predicted class is"+result)
33
+ if __name__ == "__main__":
34
+ main()