Slackbot
10/19/2022, 9:09 PMAaron Pham
10/19/2022, 9:13 PMraki
10/19/2022, 9:17 PMAaron Pham
10/19/2022, 9:17 PMraki
10/19/2022, 9:20 PMAaron Pham
10/19/2022, 9:22 PMbentoml serve service.py:svc
raki
10/19/2022, 9:24 PMAaron Pham
10/19/2022, 9:25 PMraki
10/19/2022, 9:26 PMimport bentoml
from <http://bentoml.io|bentoml.io> import JSON
model_ref = bentoml.xgboost.get("credit_risk_model:latest")
dv = model_ref.custom_objects['dictVectorizer']
model_runner = model_ref.to_runner()
svc = bentoml.Service("credit_risk_classifier", runners=[model_runner])
@svc.api(input=JSON(), output=JSON())
def classify(application_data):
vector = dv.transform(application_data)
prediction = model_runner.predict.run(vector)
print(prediction)
result = prediction[0]
if result > 0.5:
return {"status" : "DECLINED"}
elif result > 0.23:
return {"status" : "MAYBE"}
else:
return {"status" : "APPROVED"}
Aaron Pham
10/19/2022, 9:27 PMthis is using triple backtick
Aaron Pham
10/19/2022, 9:27 PM