Advertisement
Guest User

Streamlit

a guest
Oct 22nd, 2020
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. from pycaret.classification import load_model, predict_model
  2. import streamlit as st
  3. import pandas as pd
  4. model=load_model('Logistic regression')
  5.  
  6. def predict(model, input_df):
  7.        predictions_df=predict_model(estimator=model,data=input_df)
  8.        predictions=predictions_df['Label'][0]
  9.        return predictions
  10.    
  11. def run():
  12.     st.title("Welcome to Dream Finance Housing Company")
  13.     Gender=st.selectbox('Gender',['Male', 'Female'])
  14.     Married=st.selectbox('Married',['Yes', 'No'])
  15.     Dependents=st.selectbox('Dependents',['0','1','2','3+'])
  16.     Education=st.selectbox('Education',['Graduate', 'Not Graduate'])
  17.     Self_Employed=st.selectbox('Self Employed',['Yes', 'No'])
  18.     ApplicantIncome=st.number_input('Applicant Income', min_value=1, max_value=100000)
  19.     CoapplicantIncome=st.number_input('Coapplicant Income', min_value=0, max_value=100000)
  20.     LoanAmount=st.number_input('Loan Amount', min_value=1)
  21.     Loan_Amount_Term=st.selectbox('Term of Loan Amount',['60','120','180','240','300','360'])
  22.     Credit_History=st.selectbox('Credit History',['0','1'])
  23.     Property_Area=st.selectbox('Select your Area Category',['Urban','Semiurban','Rural'])
  24.     output=""
  25.     input_dict={'Gender':Gender,
  26.                 'Married': Married,
  27.                 'Dependents':Dependents,
  28.                 'Education':Education,
  29.                 'Self_Employed':Self_Employed,
  30.                'ApplicantIncome':ApplicantIncome,
  31.                'CoapplicantIncome':CoapplicantIncome,
  32.                'LoanAmount':LoanAmount,
  33.                'Loan_Amount_Term':Loan_Amount_Term,
  34.                'Credit_History':Credit_History,
  35.                'Property_Area':Property_Area}
  36.     input_df=pd.DataFrame([input_dict])
  37.     if st.button("Check"):
  38.         output=predict(model=model, input_df=input_df)
  39.         output=str(output)
  40.         st.success('Your Loan Eligibility Status {}'.format(output))
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement