Spaces:
Sleeping
Sleeping
Commit
·
ecbc519
1
Parent(s):
2198541
Upload 4 files
Browse files
dataset.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
main.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify
|
| 2 |
+
from keras.models import load_model
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import numpy as np
|
| 5 |
+
import pickle
|
| 6 |
+
|
| 7 |
+
app = Flask(__name__)
|
| 8 |
+
|
| 9 |
+
# load the model
|
| 10 |
+
model = load_model('model.h5')
|
| 11 |
+
|
| 12 |
+
# load the dataset
|
| 13 |
+
data = pd.read_csv('dataset.csv')
|
| 14 |
+
|
| 15 |
+
disease = pd.get_dummies(data['Disease'])
|
| 16 |
+
|
| 17 |
+
with open('mlb.pkl', 'rb') as f:
|
| 18 |
+
mlb = pickle.load(f)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@app.route('/predict', methods=['POST'])
|
| 22 |
+
def predict():
|
| 23 |
+
|
| 24 |
+
symptoms_to_predict = request.json['symptoms']
|
| 25 |
+
|
| 26 |
+
symptoms_array = mlb.transform([symptoms_to_predict])
|
| 27 |
+
|
| 28 |
+
disease_prediction = model.predict(np.expand_dims(symptoms_array, axis=2))
|
| 29 |
+
|
| 30 |
+
predicted_disease_index = np.argmax(disease_prediction)
|
| 31 |
+
|
| 32 |
+
predicted_disease = disease.columns[predicted_disease_index]
|
| 33 |
+
|
| 34 |
+
predicted_antibiotics = data.loc[data['Disease'] == predicted_disease, 'Antibiotics'].values[0]
|
| 35 |
+
|
| 36 |
+
output = {
|
| 37 |
+
'disease': predicted_disease,
|
| 38 |
+
'antibiotics': predicted_antibiotics
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
# return the output as JSON
|
| 42 |
+
response = jsonify(output)
|
| 43 |
+
return response
|
| 44 |
+
|
| 45 |
+
if __name__ == '__main__':
|
| 46 |
+
app.run(debug=False)
|
mlb.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:243ed1a5d8c28402ec07e767138908815c71a6d27cc52ea245f9d534a9278564
|
| 3 |
+
size 3166
|
model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:440254f8854a4b0cfb4bb6dc0d4a65b3f60efc261d5be1ca696e6564645cebcb
|
| 3 |
+
size 16940424
|