harishsohani commited on
Commit
48dec84
·
verified ·
1 Parent(s): 102f58e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -9
app.py CHANGED
@@ -231,19 +231,32 @@ if file is not None and st.button("Predict Batch"):
231
  if resp_status == "success":
232
 
233
  ## Get Sales Prediction Value
234
- predictionS_from_backend = result.get ("predictions") # Extract only the value
235
 
236
- # convert dict to dataframe for better display
237
- result_df = pd.DataFrame(list(predictionS_from_backend.items()))
238
  st.dataframe (result_df)
 
 
 
 
239
 
240
- # generate output string
241
- if prediction_from_backend == 1:
242
- resultstr = "Engine **likely** needs maintenance."
243
- else:
244
- resultstr = "Engine does not need any maintenance"
 
245
 
246
- st.success(resultstr)
 
 
 
 
 
 
 
 
 
 
247
 
248
  else:
249
 
 
231
  if resp_status == "success":
232
 
233
  ## Get Sales Prediction Value
234
+ predictions_from_backend = result.get ("predictions") # Extract only the value
235
 
 
 
236
  st.dataframe (result_df)
237
+ # Convert list → DataFrame
238
+ result_df = pd.DataFrame({
239
+ "Prediction": predictions_from_backend
240
+ })
241
 
242
+ st.dataframe (result_df)
243
+
244
+ input_df = pd.read_csv(file)
245
+
246
+ # Ensure lengths match
247
+ if len(predictions_from_backend) == len(input_df):
248
 
249
+ # Add prediction column
250
+ input_df["Prediction"] = predictions_from_backend
251
+
252
+ st.success("Batch prediction completed successfully")
253
+
254
+ # Show combined dataframe
255
+ st.dataframe(input_df, use_container_width=True)
256
+
257
+ else:
258
+ st.error("Prediction count does not match input records")
259
+
260
 
261
  else:
262