Shafanda Nabil Sembodo commited on
Commit
4e001c7
·
1 Parent(s): 2cca8d5

Add requirement file

Browse files
Files changed (2) hide show
  1. app.py +40 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ import pandas as pd
4
+ from pycaret.classification import *
5
+
6
+ os.environ['MLFLOW_TRACKING_USERNAME'] = 'fandanabil1379'
7
+ os.environ['MLFLOW_TRACKING_PASSWORD'] = 'dadc32f6246f307c2fe4928f3074068f628b79ba'
8
+
9
+ @st.cache_data
10
+ def convert_df(df):
11
+ return df.to_csv(index=False).encode('utf-8')
12
+
13
+ # init
14
+ st.set_page_config(page_title="Loan Default Prediction App")
15
+ st.title('Loan Default Prediction')
16
+
17
+ # load model
18
+ def load_model():
19
+ import mlflow
20
+ mlflow.set_tracking_uri('https://dagshub.com/fandanabil1379/loan_prediction.mlflow')
21
+ model_name = "v1.0.1"
22
+ stage = "Production"
23
+ loaded_model = mlflow.sklearn.load_model(f"models:/{model_name}/{stage}")
24
+ return loaded_model
25
+
26
+ # load data
27
+ uploaded_file = st.file_uploader("Choose a file")
28
+ if uploaded_file is not None:
29
+ # do prediction
30
+ df = pd.read_csv(uploaded_file)
31
+ model = load_model()
32
+ prediction = predict_model(model, data=df)
33
+
34
+ # show the result
35
+ st.write(prediction)
36
+
37
+ # download the result
38
+ csv = convert_df(prediction)
39
+ if st.download_button('Download Prediction', csv, 'prediction.csv'):
40
+ st.write('Thanks for downloading!')
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pandas==1.5.3
2
+ pycaret==3.0.4
3
+ scikit-learn==1.1.3
4
+ scipy==1.10.1
5
+ streamlit==1.25.0