shivansh-ka
commited on
Commit
•
3b47abb
1
Parent(s):
f965ef5
Update src/predict.py
Browse files- src/predict.py +5 -5
src/predict.py
CHANGED
@@ -32,7 +32,7 @@ class PredictionServices:
|
|
32 |
color_map = {'toxic':"red", "non-toxic":"green"}
|
33 |
fig = px.bar(x=probs,
|
34 |
y=labels,
|
35 |
-
width=
|
36 |
template="plotly_dark",
|
37 |
text_auto=True,
|
38 |
title="Probabilities(%)",
|
@@ -63,7 +63,7 @@ class PredictionServices:
|
|
63 |
df['probabilities'] = preds
|
64 |
df['toxic'] = np.where(df['probabilities']>0.5, 1, 0)
|
65 |
st.success("Prediction Process Completed!!!, :thumbsup:")
|
66 |
-
st.info("
|
67 |
return df
|
68 |
else:
|
69 |
st.error("Data Validation Failed!! :thumbsdown:")
|
@@ -73,9 +73,9 @@ class PredictionServices:
|
|
73 |
def single_predict(self, text:str):
|
74 |
try:
|
75 |
text = re.sub('\n',' ',text).strip().lower()
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
return pred
|
80 |
except Exception as e:
|
81 |
print(e)
|
|
|
32 |
color_map = {'toxic':"red", "non-toxic":"green"}
|
33 |
fig = px.bar(x=probs,
|
34 |
y=labels,
|
35 |
+
width=400, height=250,
|
36 |
template="plotly_dark",
|
37 |
text_auto=True,
|
38 |
title="Probabilities(%)",
|
|
|
63 |
df['probabilities'] = preds
|
64 |
df['toxic'] = np.where(df['probabilities']>0.5, 1, 0)
|
65 |
st.success("Prediction Process Completed!!!, :thumbsup:")
|
66 |
+
st.info("Press download button to download prediction file")
|
67 |
return df
|
68 |
else:
|
69 |
st.error("Data Validation Failed!! :thumbsdown:")
|
|
|
73 |
def single_predict(self, text:str):
|
74 |
try:
|
75 |
text = re.sub('\n',' ',text).strip().lower()
|
76 |
+
|
77 |
+
input = self.tokenizer_fn(text)
|
78 |
+
pred = self.model.predict(input)[0][0]
|
79 |
return pred
|
80 |
except Exception as e:
|
81 |
print(e)
|