Kadigas commited on
Commit
9da767a
·
1 Parent(s): d9c8574

fix: datatype for response

Browse files
Files changed (2) hide show
  1. __pycache__/main.cpython-310.pyc +0 -0
  2. main.py +4 -1
__pycache__/main.cpython-310.pyc CHANGED
Binary files a/__pycache__/main.cpython-310.pyc and b/__pycache__/main.cpython-310.pyc differ
 
main.py CHANGED
@@ -99,8 +99,11 @@ async def predict(request: Request, requess: Req = Depends(form_req)):
99
  prediction = model.predict([data])
100
  output = round(prediction[0], 2)
101
 
 
 
 
102
  # Merender index.html dengan data hasil prediksi
103
- json_compatible_resp_data = jsonable_encoder(Resp(age=requess.age, sex=sex, smoker=int(smoker),
104
  bmi=requess.bmi, children=requess.children, region=get_region_name(requess.region), insurance_cost=output))
105
  return JSONResponse(content=json_compatible_resp_data)
106
 
 
99
  prediction = model.predict([data])
100
  output = round(prediction[0], 2)
101
 
102
+ sex = "Laki-laki" if requess.sex == 1 else "Perempuan"
103
+ smoker = "Ya" if requess.smoker == 1 else "Tidak"
104
+
105
  # Merender index.html dengan data hasil prediksi
106
+ json_compatible_resp_data = jsonable_encoder(Resp(age=requess.age, sex=sex, smoker=smoker,
107
  bmi=requess.bmi, children=requess.children, region=get_region_name(requess.region), insurance_cost=output))
108
  return JSONResponse(content=json_compatible_resp_data)
109