Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -33,15 +33,32 @@ customer_data = {
|
|
| 33 |
'TotalCharges': TotalCharges
|
| 34 |
}
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
result = response.json()
|
| 41 |
churn_prediction = result["Prediction"] # Extract only the value
|
| 42 |
st.write(f"Based on the information provided, the customer with ID {CustomerID} is likely to {churn_prediction}.")
|
| 43 |
-
|
| 44 |
-
st.error("Error
|
|
|
|
| 45 |
|
| 46 |
# Batch Prediction
|
| 47 |
st.subheader("Batch Prediction")
|
|
|
|
| 33 |
'TotalCharges': TotalCharges
|
| 34 |
}
|
| 35 |
|
| 36 |
+
# Single prediction section
|
| 37 |
+
# if st.button("Predict", type='primary'):
|
| 38 |
+
# response = requests.post("https://MainiSandeep1987-BackEndFlaskAPITelecomChurnPrediction.hf.space/v1/customer", json=customer_data) # enter user name and space name before running the cell
|
| 39 |
+
# if response.status_code == 200:
|
| 40 |
+
# result = response.json()
|
| 41 |
+
# churn_prediction = result["Prediction"] # Extract only the value
|
| 42 |
+
# st.write(f"Based on the information provided, the customer with ID {CustomerID} is likely to {churn_prediction}.")
|
| 43 |
+
# else:
|
| 44 |
+
# st.error("Error in API request")
|
| 45 |
|
| 46 |
+
|
| 47 |
+
# Single prediction section
|
| 48 |
+
if st.button("Predict"):
|
| 49 |
+
try:
|
| 50 |
+
print(customer_data)
|
| 51 |
+
response = requests.post(
|
| 52 |
+
"https://MainiSandeep1987-BackEndFlaskAPITelecomChurnPrediction.hf.space/v1/customer",
|
| 53 |
+
json=input_data.to_dict(orient='records')[0]
|
| 54 |
+
) # Send data to Flask API
|
| 55 |
+
response.raise_for_status() # Raise an error if the request fails
|
| 56 |
result = response.json()
|
| 57 |
churn_prediction = result["Prediction"] # Extract only the value
|
| 58 |
st.write(f"Based on the information provided, the customer with ID {CustomerID} is likely to {churn_prediction}.")
|
| 59 |
+
except requests.exceptions.RequestException as e:
|
| 60 |
+
st.error(f"Error making prediction: {e}")
|
| 61 |
+
|
| 62 |
|
| 63 |
# Batch Prediction
|
| 64 |
st.subheader("Batch Prediction")
|