Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- app.py +53 -0
- kaggle.json +1 -0
- model.joblib +3 -0
- unique_values.joblib +3 -0
app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""app
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1FxKIGQzWkYp6AR9LCDf1hHJfeiAgni2N
|
8 |
+
"""
|
9 |
+
|
10 |
+
import joblib
|
11 |
+
import pandas as pd
|
12 |
+
import streamlit as st
|
13 |
+
|
14 |
+
model = joblib.load('model.joblib')
|
15 |
+
unique_values = joblib.load('unique_values.joblib')
|
16 |
+
|
17 |
+
unique_class = unique_values["workclass"]
|
18 |
+
unique_education = unique_values["education"]
|
19 |
+
unique_marital_status = unique_values["marital.status"]
|
20 |
+
unique_relationship = unique_values["relationship"]
|
21 |
+
unique_occupation = unique_values["occupation"]
|
22 |
+
unique_sex = unique_values["sex"]
|
23 |
+
unique_race = unique_values["race"]
|
24 |
+
unique_country = unique_values["native.country"]
|
25 |
+
def main():
|
26 |
+
st.title("Adult Income Analysis")
|
27 |
+
with st.form("questionaire"):
|
28 |
+
age = st.slider("Age", min_value=10, max_value=100)
|
29 |
+
workclass = st.selectbox("Workclass", unique_class)
|
30 |
+
education = st.selectbox("Education", unique_education)
|
31 |
+
Marital_Status = st.selectbox("Marital Status", unique_marital_status)
|
32 |
+
occupation = st.selectbox("Occupation", unique_occupation)
|
33 |
+
relationship = st.selectbox("Relationship", unique_relationship)
|
34 |
+
race = st.selectbox("Race", unique_race)
|
35 |
+
sex = st.selectbox("Sex", unique_sex)
|
36 |
+
hours_per_week = st.slider("Hours per week", min_value=1, max_value=100)
|
37 |
+
native_country = st.selectbox("Country", unique_country)
|
38 |
+
clicked = st.form_submit_button("Predict income")
|
39 |
+
if clicked:
|
40 |
+
result=model.predict(pd.DataFrame({"age": [age],
|
41 |
+
"workclass": [workclass],
|
42 |
+
"education": [education],
|
43 |
+
"marital.status": [Marital_Status],
|
44 |
+
"occupation": [occupation],
|
45 |
+
"relationship": [relationship],
|
46 |
+
"sex": [sex],
|
47 |
+
"race": [race],
|
48 |
+
"hours.per.week": [hours_per_week],
|
49 |
+
"native.country": [native_country]}))
|
50 |
+
result = '>50K' if result[0] == 1 else '<=50K'
|
51 |
+
st.success('The predicted income is {}'.format(result))
|
52 |
+
if __name__=='__main__':
|
53 |
+
main()
|
kaggle.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"username":"johnsonjoestar","key":"fce749cf190f160ba66388ab15d8b8f2"}
|
model.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25d3439c05d7692f6a9c5410744a98d72f757ef6f40836dd57b7292c1d543b35
|
3 |
+
size 300569
|
unique_values.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6d860365c89dab77a8fc16932d4aec81300745cd8a8c9831acc683f3e9335ee2
|
3 |
+
size 3835
|