Shafanda Nabil Sembodo commited on
Commit ·
3b15cbc
1
Parent(s): 5bb0e52
update
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
from pycaret.classification import *
|
|
@@ -6,41 +7,33 @@ from pycaret.classification import *
|
|
| 6 |
os.environ['MLFLOW_TRACKING_USERNAME'] = 'fandanabil1379'
|
| 7 |
os.environ['MLFLOW_TRACKING_PASSWORD'] = 'dadc32f6246f307c2fe4928f3074068f628b79ba'
|
| 8 |
|
| 9 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
def convert_df(df):
|
| 11 |
return df.to_csv(index=False).encode('utf-8')
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
st.
|
|
|
|
| 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 |
-
# @st.cache_data(experimental_allow_widgets=True)
|
| 27 |
-
def prediction():
|
| 28 |
-
# load data
|
| 29 |
uploaded_file = st.file_uploader("Choose a file", type={"csv"})
|
| 30 |
if uploaded_file is not None:
|
| 31 |
# do prediction
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
prediction = predict_model(model, df).drop(columns='Unnamed: 0')
|
| 35 |
-
return prediction
|
| 36 |
-
|
| 37 |
-
result = prediction()
|
| 38 |
|
| 39 |
-
# show the result
|
| 40 |
-
st.write(
|
| 41 |
|
| 42 |
-
# download the result
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import mlflow
|
| 3 |
import streamlit as st
|
| 4 |
import pandas as pd
|
| 5 |
from pycaret.classification import *
|
|
|
|
| 7 |
os.environ['MLFLOW_TRACKING_USERNAME'] = 'fandanabil1379'
|
| 8 |
os.environ['MLFLOW_TRACKING_PASSWORD'] = 'dadc32f6246f307c2fe4928f3074068f628b79ba'
|
| 9 |
|
| 10 |
+
# load model
|
| 11 |
+
mlflow.set_tracking_uri('https://dagshub.com/fandanabil1379/loan_prediction.mlflow')
|
| 12 |
+
model_name = "v1.0.1"
|
| 13 |
+
stage = "Production"
|
| 14 |
+
model = mlflow.sklearn.load_model(f"models:/{model_name}/{stage}")
|
| 15 |
+
|
| 16 |
+
@st.cache_data
|
| 17 |
def convert_df(df):
|
| 18 |
return df.to_csv(index=False).encode('utf-8')
|
| 19 |
|
| 20 |
+
def run():
|
| 21 |
+
# init
|
| 22 |
+
st.set_page_config(page_title="Loan Default Prediction App")
|
| 23 |
+
st.title('Loan Default Prediction')
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
uploaded_file = st.file_uploader("Choose a file", type={"csv"})
|
| 26 |
if uploaded_file is not None:
|
| 27 |
# do prediction
|
| 28 |
+
data = pd.read_csv(uploaded_file)
|
| 29 |
+
prediction = predict_model(model, data)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
# show the result
|
| 32 |
+
st.write(prediction)
|
| 33 |
|
| 34 |
+
# download the result
|
| 35 |
+
csv = convert_df(result)
|
| 36 |
+
if st.download_button('Download Prediction', csv, 'prediction.csv'):
|
| 37 |
+
st.write('Thanks for downloading!')
|
| 38 |
|
| 39 |
+
run()
|
logs.log
CHANGED
|
@@ -238,3 +238,49 @@ Feature names unseen at fit time:
|
|
| 238 |
2023-08-04 07:30:33,393:INFO:Preloading libraries
|
| 239 |
2023-08-04 07:30:33,395:INFO:Set up data.
|
| 240 |
2023-08-04 07:30:33,403:INFO:Set up index.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
2023-08-04 07:30:33,393:INFO:Preloading libraries
|
| 239 |
2023-08-04 07:30:33,395:INFO:Set up data.
|
| 240 |
2023-08-04 07:30:33,403:INFO:Set up index.
|
| 241 |
+
2023-08-08 22:18:02,376:WARNING:
|
| 242 |
+
'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
|
| 243 |
+
2023-08-08 22:18:02,376:WARNING:
|
| 244 |
+
'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
|
| 245 |
+
2023-08-08 22:18:02,376:WARNING:
|
| 246 |
+
'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
|
| 247 |
+
2023-08-08 22:18:02,376:WARNING:
|
| 248 |
+
'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
|
| 249 |
+
2023-08-08 22:26:27,519:INFO:Initializing predict_model()
|
| 250 |
+
2023-08-08 22:26:27,519:INFO:predict_model(self=<pycaret.classification.oop.ClassificationExperiment object at 0x285b30f70>, estimator=Pipeline(memory=FastMemory(location=/var/folders/vh/81ldn_315vdf1b2_lnntkb080000gn/T/joblib),
|
| 251 |
+
steps=[('combine',
|
| 252 |
+
TransformerWrapper(transformer=TransformerWrapper(include=['ed'],
|
| 253 |
+
transformer=Combine()))),
|
| 254 |
+
('remove outlier',
|
| 255 |
+
TransformerWrapper(transformer=TransformerWrapper(transformer=RemoveOutliers(random_state=42)))),
|
| 256 |
+
('normalize',
|
| 257 |
+
TransformerWrapper(transformer=TransformerWrapper(exclude=['ed',
|
| 258 |
+
'age'],
|
| 259 |
+
transformer=RobustScaler()))),
|
| 260 |
+
('actual_estimator',
|
| 261 |
+
LogisticRegression(C=8.956999999999999,
|
| 262 |
+
class_weight='balanced', max_iter=1000,
|
| 263 |
+
random_state=42))]), probability_threshold=None, encoded_labels=False, raw_score=False, round=4, verbose=True, ml_usecase=None, preprocess=True, encode_labels=<function _SupervisedExperiment.predict_model.<locals>.encode_labels at 0x2857929d0>)
|
| 264 |
+
2023-08-08 22:26:27,519:INFO:Checking exceptions
|
| 265 |
+
2023-08-08 22:26:27,519:INFO:Preloading libraries
|
| 266 |
+
2023-08-08 22:26:27,522:INFO:Set up data.
|
| 267 |
+
2023-08-08 22:26:27,534:INFO:Set up index.
|
| 268 |
+
2023-08-08 22:27:05,991:INFO:Initializing predict_model()
|
| 269 |
+
2023-08-08 22:27:05,992:INFO:predict_model(self=<pycaret.classification.oop.ClassificationExperiment object at 0x16e1b5100>, estimator=Pipeline(memory=FastMemory(location=/var/folders/vh/81ldn_315vdf1b2_lnntkb080000gn/T/joblib),
|
| 270 |
+
steps=[('combine',
|
| 271 |
+
TransformerWrapper(transformer=TransformerWrapper(include=['ed'],
|
| 272 |
+
transformer=Combine()))),
|
| 273 |
+
('remove outlier',
|
| 274 |
+
TransformerWrapper(transformer=TransformerWrapper(transformer=RemoveOutliers(random_state=42)))),
|
| 275 |
+
('normalize',
|
| 276 |
+
TransformerWrapper(transformer=TransformerWrapper(exclude=['ed',
|
| 277 |
+
'age'],
|
| 278 |
+
transformer=RobustScaler()))),
|
| 279 |
+
('actual_estimator',
|
| 280 |
+
LogisticRegression(C=8.956999999999999,
|
| 281 |
+
class_weight='balanced', max_iter=1000,
|
| 282 |
+
random_state=42))]), probability_threshold=None, encoded_labels=False, raw_score=False, round=4, verbose=True, ml_usecase=None, preprocess=True, encode_labels=<function _SupervisedExperiment.predict_model.<locals>.encode_labels at 0x16e1c3550>)
|
| 283 |
+
2023-08-08 22:27:05,992:INFO:Checking exceptions
|
| 284 |
+
2023-08-08 22:27:05,992:INFO:Preloading libraries
|
| 285 |
+
2023-08-08 22:27:05,992:INFO:Set up data.
|
| 286 |
+
2023-08-08 22:27:05,998:INFO:Set up index.
|