Spaces:
Runtime error
Runtime error
Update app_1.py
Browse files
app_1.py
CHANGED
@@ -2,67 +2,56 @@ import joblib
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
-
|
6 |
-
'
|
7 |
-
'
|
8 |
-
'
|
9 |
-
'
|
10 |
-
'
|
11 |
-
'
|
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 = joblib.load('
|
24 |
-
unique_values = joblib.load('
|
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("
|
37 |
|
38 |
with st.form("questionaire"):
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
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({"
|
54 |
-
"
|
55 |
-
"
|
56 |
-
"
|
57 |
-
"
|
58 |
-
"
|
59 |
-
"
|
60 |
-
"
|
61 |
-
"
|
62 |
-
"
|
|
|
|
|
|
|
63 |
# Show prediction
|
64 |
-
result = '
|
65 |
-
st.success("Your predicted
|
66 |
|
67 |
# Run main()
|
68 |
if __name__ == "__main__":
|
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
+
purpose_1 = {'all_other': 1,
|
6 |
+
'credit_card': 2,
|
7 |
+
'debt_consolidation': 3,
|
8 |
+
'educational': 4,
|
9 |
+
'home_improvement': 5,
|
10 |
+
'major_purchase': 6,
|
11 |
+
'small_business': 7,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
13 |
|
14 |
+
model = joblib.load('model_1.joblib')
|
15 |
+
unique_values = joblib.load('unique_values_1.joblib')
|
16 |
+
unique_Purpose = unique_values["purpose"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def main():
|
19 |
+
st.title("Loan Data")
|
20 |
|
21 |
with st.form("questionaire"):
|
22 |
+
purpose = st.selectbox("Purpose", options = unique_Purpose )
|
23 |
+
int_rate = st.slider("The interest rate of the loan", 0.0000,1.0000)
|
24 |
+
installments = st.number_input("The monthly installments owed")
|
25 |
+
log_annual_inc = st.number_input("The natural log of the self-reported annual income of the borrower")
|
26 |
+
dti = st.number_input("The debt to income ratio of the borrower")
|
27 |
+
fico = st.slider("The FICO credit score of the borrower.", 0,1000)
|
28 |
+
days_with_cr_line = st.number_input("The number of days the borrower has had a credit line.")
|
29 |
+
revol_bal = st.number_input("The borrower's revolving balance")
|
30 |
+
revol_util= st.number_input("The borrower's revolving line utilization rate")
|
31 |
+
inq_last_6mths= st.slider("The borrower's number of inquiries by creditors in the last 6 months.", 0,100)
|
32 |
+
delinq_2yrs = st.slider("The number of times the borrower had been 30+ days past due on a payment in the past 2 year", 0,100 )
|
33 |
+
pub_rec= st.slider("The borrower's number of derogatory public records", 0,100 )
|
34 |
+
not_fully_paid = st.slider("not fully paid.", 0,100)
|
35 |
+
|
36 |
# clicked==True only when the button is clicked
|
37 |
clicked = st.form_submit_button("Predict income")
|
38 |
if clicked:
|
39 |
+
result=model.predict(pd.DataFrame({"purpose": [purpose_1],
|
40 |
+
"int.rate": [int_rate],
|
41 |
+
"installment": [installments],
|
42 |
+
"log.annual.inc": [log_annual_inc],
|
43 |
+
"dti": [dti],
|
44 |
+
"fico": [fico],
|
45 |
+
"days.with.cr.line": [days_with_cr_line],
|
46 |
+
"revol.bal": [revol_bal],
|
47 |
+
"revol.util": [revol_util],
|
48 |
+
"inq.last.6mths": [inq_last_6mths]
|
49 |
+
"delinq.2yrs": [delinq_2yrs]
|
50 |
+
"pub.rec": [pub_rec]
|
51 |
+
"not.fully.paid": [not_fully_paid]}))
|
52 |
# Show prediction
|
53 |
+
result = 'Pass' if result[0] == 1 else 'Not Pass'
|
54 |
+
st.success("Your predicted loan is "+result) #แสดงผล
|
55 |
|
56 |
# Run main()
|
57 |
if __name__ == "__main__":
|