Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,11 +30,13 @@ def predict_need_maintenance ():
|
|
| 30 |
|
| 31 |
validated_df = validate_and_prepare_input(input_df, model)
|
| 32 |
|
| 33 |
-
prediction
|
|
|
|
| 34 |
|
| 35 |
return jsonify({
|
| 36 |
"status": "success",
|
| 37 |
-
"prediction": int(prediction)
|
|
|
|
| 38 |
})
|
| 39 |
|
| 40 |
except InputValidationError as e:
|
|
@@ -105,15 +107,18 @@ def predict_need_maintenance_for_batch ():
|
|
| 105 |
validated_df = validate_and_prepare_input(input_df, model)
|
| 106 |
|
| 107 |
# predict for given input
|
| 108 |
-
predictions
|
|
|
|
| 109 |
|
| 110 |
# Convert numpy array → Python list
|
| 111 |
-
prediction_list
|
|
|
|
| 112 |
|
| 113 |
return jsonify({
|
| 114 |
-
"status": "success",
|
| 115 |
"total_records": len(prediction_list),
|
| 116 |
-
"predictions": prediction_list,
|
|
|
|
| 117 |
})
|
| 118 |
|
| 119 |
except InputValidationError as e:
|
|
|
|
| 30 |
|
| 31 |
validated_df = validate_and_prepare_input(input_df, model)
|
| 32 |
|
| 33 |
+
prediction = model.predict(validated_df)[0]
|
| 34 |
+
probability = model.predict_proba(validated_df)[0, 1]
|
| 35 |
|
| 36 |
return jsonify({
|
| 37 |
"status": "success",
|
| 38 |
+
"prediction": int(prediction),
|
| 39 |
+
"probability": float(probability)
|
| 40 |
})
|
| 41 |
|
| 42 |
except InputValidationError as e:
|
|
|
|
| 107 |
validated_df = validate_and_prepare_input(input_df, model)
|
| 108 |
|
| 109 |
# predict for given input
|
| 110 |
+
predictions = model.predict(validated_df)
|
| 111 |
+
probabilities = model.predict_proba(validated_df)[:, 1]
|
| 112 |
|
| 113 |
# Convert numpy array → Python list
|
| 114 |
+
prediction_list = predictions.tolist()
|
| 115 |
+
probabilities_list = probabilities.tolist()
|
| 116 |
|
| 117 |
return jsonify({
|
| 118 |
+
"status": "success", # overall batch status
|
| 119 |
"total_records": len(prediction_list),
|
| 120 |
+
"predictions": prediction_list, # simple list version
|
| 121 |
+
"probabilities": probabilities_list, # simple list version
|
| 122 |
})
|
| 123 |
|
| 124 |
except InputValidationError as e:
|