Commit ·
77b9b1d
1
Parent(s): 75b9644
Fix credit risk app paths for standalone Space deployment
Browse files
app.py
CHANGED
|
@@ -2,16 +2,19 @@
|
|
| 2 |
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
|
|
|
| 5 |
|
| 6 |
from sklearn.metrics import f1_score, precision_score, recall_score, confusion_matrix
|
| 7 |
|
| 8 |
import pickle
|
| 9 |
import gradio as gr
|
| 10 |
|
|
|
|
|
|
|
| 11 |
## CREATING FUNCTION
|
| 12 |
|
| 13 |
def predict_credit_worthiness(name, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22):
|
| 14 |
-
path =
|
| 15 |
greet = 'Hey, ' + name + '!'
|
| 16 |
with open(path, 'rb') as file:
|
| 17 |
model = pickle.load(file)
|
|
@@ -40,10 +43,10 @@ def predict_credit_worthiness(name, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11
|
|
| 40 |
}
|
| 41 |
prediction = model.predict([list(inputs.values())])
|
| 42 |
|
| 43 |
-
y_test = pd.read_parquet(
|
| 44 |
y_test = y_test.squeeze()
|
| 45 |
|
| 46 |
-
yhat = pd.read_parquet(
|
| 47 |
yhat = yhat.squeeze()
|
| 48 |
|
| 49 |
precision = precision_score(y_test, yhat).round(2)
|
|
|
|
| 2 |
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
| 5 |
+
from pathlib import Path
|
| 6 |
|
| 7 |
from sklearn.metrics import f1_score, precision_score, recall_score, confusion_matrix
|
| 8 |
|
| 9 |
import pickle
|
| 10 |
import gradio as gr
|
| 11 |
|
| 12 |
+
BASE_DIR = Path(__file__).resolve().parent
|
| 13 |
+
|
| 14 |
## CREATING FUNCTION
|
| 15 |
|
| 16 |
def predict_credit_worthiness(name, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22):
|
| 17 |
+
path = BASE_DIR / "model" / "model.pickle"
|
| 18 |
greet = 'Hey, ' + name + '!'
|
| 19 |
with open(path, 'rb') as file:
|
| 20 |
model = pickle.load(file)
|
|
|
|
| 43 |
}
|
| 44 |
prediction = model.predict([list(inputs.values())])
|
| 45 |
|
| 46 |
+
y_test = pd.read_parquet(BASE_DIR / "data" / "processed" / "y_test.parquet")
|
| 47 |
y_test = y_test.squeeze()
|
| 48 |
|
| 49 |
+
yhat = pd.read_parquet(BASE_DIR / "data" / "processed" / "yhat.parquet")
|
| 50 |
yhat = yhat.squeeze()
|
| 51 |
|
| 52 |
precision = precision_score(y_test, yhat).round(2)
|