Spaces:
Sleeping
Sleeping
Upload predict.py
Browse files- predict.py +28 -9
predict.py
CHANGED
|
@@ -55,25 +55,44 @@ def run():
|
|
| 55 |
st.title("π Customer Churn Prediction")
|
| 56 |
st.markdown('---')
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
st.write("## βπ»π Input Data: ")
|
| 59 |
st.write("") # Add a blank line for spacing
|
|
|
|
| 60 |
with st.form(key="data"):
|
| 61 |
col1, col2 = st.columns(2)
|
| 62 |
with col1:
|
| 63 |
-
customer_id = st.text_input("Customer ID")
|
| 64 |
-
tenure = st.number_input("Tenure")
|
| 65 |
with col2:
|
| 66 |
contract = st.selectbox(
|
| 67 |
-
"contract", ['one year', 'month-to-month', 'two year']
|
| 68 |
)
|
| 69 |
payment_method = st.selectbox(
|
| 70 |
-
"payment_method", ['credit card', 'electronic check', 'bank transfer', 'mailed check']
|
| 71 |
)
|
| 72 |
-
monthly_charges = st.number_input("Monthly charges")
|
| 73 |
-
total_charges = st.number_input("Total charges")
|
| 74 |
-
feedback = st.text_area(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
topic = st.selectbox(
|
| 76 |
-
"topic", ['bouquet preferences', 'delivery issues', 'general feedback', 'price complaints', 'delivery quality', 'product quality', 'customer service', 'price appreciation']
|
| 77 |
)
|
| 78 |
# Submit button
|
| 79 |
submit = st.form_submit_button("π Predict")
|
|
@@ -141,4 +160,4 @@ def run():
|
|
| 141 |
st.balloons()
|
| 142 |
|
| 143 |
if __name__ == "__main__":
|
| 144 |
-
run()
|
|
|
|
| 55 |
st.title("π Customer Churn Prediction")
|
| 56 |
st.markdown('---')
|
| 57 |
|
| 58 |
+
st.sidebar.markdown("---")
|
| 59 |
+
|
| 60 |
+
st.sidebar.write("### BERT Model")
|
| 61 |
+
st.sidebar.write("This application uses a BERT model to analyze the sentiment of customer feedback. BERT is highly effective at understanding context and nuances in text, even for long feedback, despite being trained on shorter sentences in our dataset.")
|
| 62 |
+
st.sidebar.image("bert.jpg", width=200)
|
| 63 |
+
st.sidebar.write("BERT (Bidirectional Encoder Representations from Transformers) works by understanding the context of words in a sentence by looking at the words that come before and after them. This bidirectional approach allows BERT to capture the meaning of words more accurately.")
|
| 64 |
+
|
| 65 |
+
st.sidebar.markdown('---') # Line separating between models
|
| 66 |
+
|
| 67 |
+
st.sidebar.write("### SVM Classifier")
|
| 68 |
+
st.sidebar.write("After sentiment analysis, an SVM classifier is used to predict whether a customer is likely to churn based on the sentiment and other features provided.")
|
| 69 |
+
st.sidebar.image("svm.png", width=200)
|
| 70 |
+
st.sidebar.write("SVM (Support Vector Machine) works by finding the hyperplane that best separates the data into different classes. In this case, it uses the sentiment and other features to predict customer churn.")
|
| 71 |
+
|
| 72 |
st.write("## βπ»π Input Data: ")
|
| 73 |
st.write("") # Add a blank line for spacing
|
| 74 |
+
st.write("This prediction will be done by first analyzing the sentiment from the feedback provided using a BERT model. The sentiment, along with other features, will then be used to classify whether the customer is likely to churn or not churn using an SVM classifier.")
|
| 75 |
with st.form(key="data"):
|
| 76 |
col1, col2 = st.columns(2)
|
| 77 |
with col1:
|
| 78 |
+
customer_id = st.text_input("Customer ID", value="CUST001")
|
| 79 |
+
tenure = st.number_input("Tenure (in months)", value=12)
|
| 80 |
with col2:
|
| 81 |
contract = st.selectbox(
|
| 82 |
+
"contract", ['one year', 'month-to-month', 'two year'], index=1
|
| 83 |
)
|
| 84 |
payment_method = st.selectbox(
|
| 85 |
+
"payment_method", ['credit card', 'electronic check', 'bank transfer', 'mailed check'],index=0
|
| 86 |
)
|
| 87 |
+
monthly_charges = st.number_input("Monthly charges (in $)",step=1.00)
|
| 88 |
+
total_charges = st.number_input("Total charges (in $)",step=1.00)
|
| 89 |
+
feedback = st.text_area(
|
| 90 |
+
"Feedback",
|
| 91 |
+
value="As an event planner, I've worked with many florists, but this one stands out from the crowd. For a recent high-profile corporate gala, they provided centerpieces that were nothing short of spectacular. The creativity and artistry in their designs elevated the entire event. They listened carefully to our theme and color scheme, then created arrangements that perfectly captured the essence of the evening. The flowers were fresh, vibrant, and lasted throughout the night, even under bright lights and air conditioning. What impressed me most was their flexibility - when we needed last-minute changes due to a shift in table arrangements, they accommodated without hesitation. Their team was professional, punctual, and a joy to work with. They arrived well before the event to set up and stayed until everything was perfect. The value for money was excellent, considering the high-quality results and the level of service provided. I've already booked them for several upcoming events, including a charity fundraiser and a product launch. It's rare to find a vendor that consistently exceeds expectations, but this florist does just that.",
|
| 92 |
+
height=300
|
| 93 |
+
)
|
| 94 |
topic = st.selectbox(
|
| 95 |
+
"topic", ['bouquet preferences', 'delivery issues', 'general feedback', 'price complaints', 'delivery quality', 'product quality', 'customer service', 'price appreciation'], index=2
|
| 96 |
)
|
| 97 |
# Submit button
|
| 98 |
submit = st.form_submit_button("π Predict")
|
|
|
|
| 160 |
st.balloons()
|
| 161 |
|
| 162 |
if __name__ == "__main__":
|
| 163 |
+
run()
|