Spaces:
Sleeping
Sleeping
Upload predict.py
Browse files- predict.py +13 -4
predict.py
CHANGED
|
@@ -99,7 +99,7 @@ def run():
|
|
| 99 |
"Sample 3": {
|
| 100 |
"customer_id": "CUST003",
|
| 101 |
"tenure": 6,
|
| 102 |
-
"contract": "
|
| 103 |
"payment_method": "bank transfer",
|
| 104 |
"monthly_charges": 400000.00,
|
| 105 |
"total_charges": 2400000.00,
|
|
@@ -187,7 +187,12 @@ def run():
|
|
| 187 |
labels, confidences = predict_sentiment([feedback])
|
| 188 |
label = labels[0]
|
| 189 |
confidence = confidences[0]
|
| 190 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
st.info(f"Confidence: {confidence * 100:.2f}%")
|
| 192 |
data['sentiment'] = label
|
| 193 |
else:
|
|
@@ -200,7 +205,7 @@ def run():
|
|
| 200 |
# Load customer churn model
|
| 201 |
status_text.text("Loading churn prediction model...")
|
| 202 |
for i in range(50, 75):
|
| 203 |
-
time.sleep(0.
|
| 204 |
progress_bar.progress(i + 1)
|
| 205 |
|
| 206 |
with open('model.pkl', 'rb') as file_1:
|
|
@@ -208,7 +213,7 @@ def run():
|
|
| 208 |
|
| 209 |
status_text.text("Predicting churn...")
|
| 210 |
for i in range(75, 100):
|
| 211 |
-
time.sleep(0.
|
| 212 |
progress_bar.progress(i + 1)
|
| 213 |
|
| 214 |
churn = classification.predict(data)
|
|
@@ -227,6 +232,10 @@ def run():
|
|
| 227 |
st.success("π Customer is Not Gonna Churn")
|
| 228 |
st.image('sss.png')
|
| 229 |
st.balloons()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
else:
|
| 231 |
if any(element for element in churn_bool):
|
| 232 |
st.error("π **Customer is Gonna Churn!!**")
|
|
|
|
| 99 |
"Sample 3": {
|
| 100 |
"customer_id": "CUST003",
|
| 101 |
"tenure": 6,
|
| 102 |
+
"contract": "two year",
|
| 103 |
"payment_method": "bank transfer",
|
| 104 |
"monthly_charges": 400000.00,
|
| 105 |
"total_charges": 2400000.00,
|
|
|
|
| 187 |
labels, confidences = predict_sentiment([feedback])
|
| 188 |
label = labels[0]
|
| 189 |
confidence = confidences[0]
|
| 190 |
+
st.write("**Feedback:**")
|
| 191 |
+
st.write(feedback)
|
| 192 |
+
if label == "Negative":
|
| 193 |
+
st.error(f"Predicted Sentiment: **{label}**")
|
| 194 |
+
else:
|
| 195 |
+
st.success(f"Predicted Sentiment: **{label}**")
|
| 196 |
st.info(f"Confidence: {confidence * 100:.2f}%")
|
| 197 |
data['sentiment'] = label
|
| 198 |
else:
|
|
|
|
| 205 |
# Load customer churn model
|
| 206 |
status_text.text("Loading churn prediction model...")
|
| 207 |
for i in range(50, 75):
|
| 208 |
+
time.sleep(0.01)
|
| 209 |
progress_bar.progress(i + 1)
|
| 210 |
|
| 211 |
with open('model.pkl', 'rb') as file_1:
|
|
|
|
| 213 |
|
| 214 |
status_text.text("Predicting churn...")
|
| 215 |
for i in range(75, 100):
|
| 216 |
+
time.sleep(0.01)
|
| 217 |
progress_bar.progress(i + 1)
|
| 218 |
|
| 219 |
churn = classification.predict(data)
|
|
|
|
| 232 |
st.success("π Customer is Not Gonna Churn")
|
| 233 |
st.image('sss.png')
|
| 234 |
st.balloons()
|
| 235 |
+
st.write('### π Feedback To Marketing Team: ')
|
| 236 |
+
st.warning("""
|
| 237 |
+
The customer is not going to churn as long as we continue delivering consistent value, addressing their needs effectively, and providing exceptional service that keeps them satisfied and engaged. By maintaining open communication, offering personalized experiences, and responding quickly to any issues, we can ensure their loyalty and reduce the likelihood of churn.
|
| 238 |
+
""")
|
| 239 |
else:
|
| 240 |
if any(element for element in churn_bool):
|
| 241 |
st.error("π **Customer is Gonna Churn!!**")
|