- Create python virtual environment
python3 -m venv venv
- Activate virtual environment
source venv/bin/activate
- Install library needed in requirements.txt
pip install -r requirements.txt
-
Open terminal and type
flask -app flaskr/webserver run
-
Hit API Endpoint with Web API Testing Client (Thunder Client, Postman API, etc.)
-
Get Prediction
json = { column1: value1, column2: value2, ... } requests.post('/predict/', data=json)
-
Get Recommendation
json = { column1: value1, # user existing lifestyle column2: value2, ... columnN: valueN # user characteristic } requests.post('/recommendation/', data=json)
Will get the result of user recommended lifestyle with risk comparison with existing lifestyle. Here are one of response example
"lifestyle" : { "Column1": { "changeStatus": "True", "comparison": "<= 140.372 (-0.001-140.372)", "description": "Minutes outdoors 9am - 5pm not work day", "recommendedValueInterval": "(-0.001, 140.372]" }, "ColumnN": { "changeStatus": "Status of change compared with existing user lifestyle", "comparison": "<= 140.372 (-0.001-140.372)", "description": "Lifestyle description", "recommendedValueInterval": "(pd.Interval]" } }, "currentRisk": 99.98880624771118, "riskAfterRecommendation": 0.022367404017132, "riskReduction": 99.96643884369405, "timeGenerated": "2024-05-17", "timeTaken": "14.709s" "status": 200, "statusMessage": "Success retrieving recommendation data"
-
Get accepted data schema for JSON data by accessing both endpoint with GET HTTP Request method.