-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict.py
More file actions
34 lines (24 loc) · 770 Bytes
/
Copy pathpredict.py
File metadata and controls
34 lines (24 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pickle
import xgboost as xgb
from flask import Flask, jsonify, request
model_file = "model.bin"
with open(model_file, "rb") as f_in:
dv, model = pickle.load(f_in)
app = Flask("diabeties")
@app.route("/predict", methods=['POST'])
def predict():
person = request.get_json()
X = dv.transform([person])
dX = xgb.DMatrix(X, feature_names=dv.get_feature_names())
y_pred = model.predict(dX)[0]
heartdisease = y_pred >= 0.5
result = {
"probability": float(y_pred),
"Diabeties": bool(heartdisease),
}
return jsonify(result)
@app.route('/test', methods = ['GET'])
def test():
return '<h1>Hello to Diabetes Prediction Server</h1>'
if __name__ == "__main__":
app.run(debug=True, host="0.0.0.0", port=9696)