Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to let deployed classifier return probabilities? #394

Open
caojianneng opened this issue Dec 30, 2021 · 0 comments
Open

How to let deployed classifier return probabilities? #394

caojianneng opened this issue Dec 30, 2021 · 0 comments

Comments

@caojianneng
Copy link

Description of the problem:

#Let the random-forest model be: rf_model

from kale.common.serveutils import serve
kfserver = serve(rf_model) #model is deployed

#prepare data for prediction
data = [row.tolist() for _, row in train_df[predictor_var].head(10).iterrows()]
data_json = json.dumps({"instances": data})

#prediciton:
pred = kfserver.predict(data_json)

Question 1: The returned pred is class labels: 0/1. How to return probabilities?

I tried the following way after studying: kale.common.serveutils.predict
#let HOST be the host name of deployed model
#let the URL of calling the deployed model be: http://xxx:predict
headers = {"content-type": "application/json", "Host": HOST}
pred_2 = requests.post(url = URL,
data=data_json,
headers=headers)

Question 2: But not clear, where to set parameter, so pred_2 will return probabilities?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant