LovnishVerma commited on
Commit
358cc5a
·
verified ·
1 Parent(s): 88ea7df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -21,12 +21,17 @@ except:
21
  @app.route("/predict", methods=["POST"])
22
  def predict():
23
  data = request.json
24
- features = [data["sepal_length"], data["sepal_width"],
25
- data["petal_length"], data["petal_width"]]
26
- prediction = model.predict([features])[0]
 
 
 
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)