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