Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,12 +21,17 @@ except:
|
|
| 21 |
@app.route("/predict", methods=["POST"])
|
| 22 |
def predict():
|
| 23 |
data = request.json
|
| 24 |
-
features = [
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
|
|
|
| 28 |
target_names = load_iris().target_names
|
| 29 |
-
return jsonify({"prediction": target_names[prediction]})
|
|
|
|
| 30 |
|
| 31 |
if __name__ == "__main__":
|
| 32 |
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 21 |
@app.route("/predict", methods=["POST"])
|
| 22 |
def predict():
|
| 23 |
data = request.json
|
| 24 |
+
features = [
|
| 25 |
+
data["sepal_length"],
|
| 26 |
+
data["sepal_width"],
|
| 27 |
+
data["petal_length"],
|
| 28 |
+
data["petal_width"]
|
| 29 |
+
]
|
| 30 |
|
| 31 |
+
prediction = model.predict([features])[0] # Get scalar (0,1,2)
|
| 32 |
target_names = load_iris().target_names
|
| 33 |
+
return jsonify({"prediction": target_names[int(prediction)]})
|
| 34 |
+
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|
| 37 |
app.run(host="0.0.0.0", port=7860)
|