Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -76,7 +76,7 @@ if submit:
|
|
| 76 |
st.error("Please fill in all the required fields")
|
| 77 |
else:
|
| 78 |
df = pd.DataFrame([user_input])
|
| 79 |
-
proba = model.predict_proba(df)[:, 1]
|
| 80 |
pred = (proba >= decision_threshold).astype(int)
|
| 81 |
|
| 82 |
st.divider()
|
|
@@ -84,12 +84,12 @@ if submit:
|
|
| 84 |
res_col1, res_col2 = st.columns([1, 2])
|
| 85 |
with res_col1:
|
| 86 |
if pred == 1:
|
| 87 |
-
confidence =
|
| 88 |
st.success("### YES")
|
| 89 |
else:
|
| 90 |
-
confidence =
|
| 91 |
st.error("### NO")
|
| 92 |
with res_col2:
|
| 93 |
st.write(f"**Model Certainty:**")
|
| 94 |
-
st.progress(
|
| 95 |
st.balloons()
|
|
|
|
| 76 |
st.error("Please fill in all the required fields")
|
| 77 |
else:
|
| 78 |
df = pd.DataFrame([user_input])
|
| 79 |
+
proba = model.predict_proba(df)[:, 1] # class 1
|
| 80 |
pred = (proba >= decision_threshold).astype(int)
|
| 81 |
|
| 82 |
st.divider()
|
|
|
|
| 84 |
res_col1, res_col2 = st.columns([1, 2])
|
| 85 |
with res_col1:
|
| 86 |
if pred == 1:
|
| 87 |
+
confidence = proba[0] * 100
|
| 88 |
st.success("### YES")
|
| 89 |
else:
|
| 90 |
+
confidence = (1 - proba[0]) * 100
|
| 91 |
st.error("### NO")
|
| 92 |
with res_col2:
|
| 93 |
st.write(f"**Model Certainty:**")
|
| 94 |
+
st.progress(proba[0] if pred == 1 else 1 - proba[0], text=f"Confidence: {round(confidence, 2)}%")
|
| 95 |
st.balloons()
|
util2.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
|
| 2 |
from sklearn.base import BaseEstimator, TransformerMixin
|
| 3 |
-
from huggingface_hub import HfApi
|
| 4 |
-
import pandas as pd
|
| 5 |
import numpy as np
|
| 6 |
-
import os
|
| 7 |
|
| 8 |
class IQRCapper(BaseEstimator, TransformerMixin):
|
| 9 |
def __init__(self, factor=1.5):
|
|
@@ -28,22 +25,3 @@ class IQRCapper(BaseEstimator, TransformerMixin):
|
|
| 28 |
|
| 29 |
def set_output(self, transform=None):
|
| 30 |
return self
|
| 31 |
-
|
| 32 |
-
## train test split from HF ##
|
| 33 |
-
def get_train_test_split():
|
| 34 |
-
HF_REPO = os.getenv("HF_REPO")
|
| 35 |
-
hfApi = HfApi(token=os.getenv("HF_TOKEN"))
|
| 36 |
-
|
| 37 |
-
# Checking train/test splits are present or not
|
| 38 |
-
files = ["train", "test"]
|
| 39 |
-
for f in files:
|
| 40 |
-
path = f"hf://datasets/{HF_REPO}/{f}.csv"
|
| 41 |
-
try:
|
| 42 |
-
pd.read_csv(path, nrows=1)
|
| 43 |
-
except FileNotFoundError:
|
| 44 |
-
raise RuntimeError(f"{f}.csv missing @HF Dataset")
|
| 45 |
-
except Exception as e:
|
| 46 |
-
raise RuntimeError(f"Error Checking Path: {path} | Err: {e}")
|
| 47 |
-
|
| 48 |
-
return f"https://huggingface.co/datasets/{HF_REPO}/resolve/main/train.csv", \
|
| 49 |
-
f"https://huggingface.co/datasets/{HF_REPO}/resolve/main/test.csv",
|
|
|
|
| 1 |
|
| 2 |
from sklearn.base import BaseEstimator, TransformerMixin
|
|
|
|
|
|
|
| 3 |
import numpy as np
|
|
|
|
| 4 |
|
| 5 |
class IQRCapper(BaseEstimator, TransformerMixin):
|
| 6 |
def __init__(self, factor=1.5):
|
|
|
|
| 25 |
|
| 26 |
def set_output(self, transform=None):
|
| 27 |
return self
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|