| import os | |
| import mlflow | |
| import streamlit as st | |
| import pandas as pd | |
| from pycaret.classification import * | |
| # os.environ['MLFLOW_TRACKING_USERNAME'] = 'fandanabil1379' | |
| # os.environ['MLFLOW_TRACKING_PASSWORD'] = 'dadc32f6246f307c2fe4928f3074068f628b79ba' | |
| # # load model | |
| # mlflow.set_tracking_uri('https://dagshub.com/fandanabil1379/loan_prediction.mlflow') | |
| # model_name = "v1.0.1" | |
| # stage = "Production" | |
| # model = mlflow.sklearn.load_model(f"models:/{model_name}/{stage}") | |
| model = load_model('model') | |
| def convert_df(df): | |
| return df.to_csv(index=False).encode('utf-8') | |
| def run(): | |
| # init | |
| st.set_page_config(page_title="Loan Default Prediction App") | |
| st.title('Loan Default Prediction') | |
| uploaded_file = st.file_uploader("Choose a file", type={"csv"}) | |
| if uploaded_file is not None: | |
| # do prediction | |
| data = pd.read_csv(uploaded_file) | |
| prediction = model[-1].predict(data.iloc[:, :-1]) | |
| print(prediction) | |
| # show the result | |
| # st.write(prediction) | |
| # download the result | |
| # csv = convert_df(prediction) | |
| # if st.download_button('Download Prediction', csv, 'prediction.csv'): | |
| # st.write('Thanks for downloading!') | |
| run() |