Commit 211b4ac9 authored by Kavindu Randika's avatar Kavindu Randika

Merge branch 'dev-it18141252' into 'master'

Symptoms API

See merge request !5
parents 4c92ffa2 03b7cf73
......@@ -11,7 +11,7 @@
## run Server
- .\env\Scripts\activate
- uvicorn index:app --reload
- uvicorn main:app --reload
## Export Dependencies
......
{"23,2,8,9,11,12,68,15": "Acne Symptoms", "4,28,0,0,0,0,0,0": "Rosacea Symptoms", "53,32,6,21,39,0,0,0": "actinic keratosis symptoms", "84,81,82,72,85,0,0,0": "Atopic dermatitis", "37,42,55,27,0,0,0,0": "Bullous disease symptoms", "49,61,63,46,67,31,51,16": "Cellulitis Symptoms", "86,76,73,78,0,0,0,0": "Eczema Symptoms", "33,10,30,57,0,0,0,0": "Exanthems Symptoms", "56,47,34,70,7,5,0,0": "Alopecia symptoms", "75,71,45,13,0,0,0,0": "Herpes HPV symptoms", "79,77,74,83,0,0,0,0": "Light Disease Symptoms", "44,48,20,35,60,41,43,0": "lupus symptoms", "1,18,22,3,29,0,0,0": "melanoma symptoms", "66,69,19,25,14,59,0,0": "Nail Fungus symptoms", "52,40,61,17,24,0,0,0": "poison ivy symptoms", "50,58,26,38,65,62,0,0": "psoriasis symptoms", "36,80,54,64,0,0,0,0": "Scabies symptoms"}
\ No newline at end of file
from fastapi import FastAPI
from routes.disease import disease
from routes.doctor import doctor
from routes.prediction import prediction
app = FastAPI()
app.include_router(disease)
app.include_router(doctor)
app.include_router(prediction)
from typing import List
from fastapi import APIRouter
from os import error
import pandas as pd
import numpy as np
import json
import os
prediction = APIRouter()
def load_data_json(path=''):
with open(path, 'r') as fp:
data = json.load(fp)
fp.close()
return data
@prediction.get('/api/predictions/symptoms')
async def predict_symptoms():
try:
data = load_data_json('../config/data.json')
threshold = 0.5
input = set([79,77])
output = []
for key in data.keys():
numbers = [int(i) for i in key.split(',') if int(i) != 0]
lenght = len(numbers)
score = len(list(input&set(numbers)))/lenght
if score>=threshold:
output.append(data.get(key))
return {"success": True, "result": output}
except error:
return {"success": False, "msg": error}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment