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

Question on function that provides probability or confidence values for a prediction #123

Closed
SrikrishnaBhat opened this issue Mar 13, 2024 · 2 comments

Comments

@SrikrishnaBhat
Copy link

I had a look at the API reference and must have missed it. I would like to know if adapt has an option to provide probability/confidence values for a prediction similar to scikit-learn's and XGBoost's predict_proba function. If not, is it possible to add it?

@antoinedemathelin
Copy link
Collaborator

Hi @SrikrishnaBhat,
Yes, if you use a sklearn estimator, you can access every methods of the estimator through the estimator_ attribute. Here is a small example:

import numpy as np
from adapt.instance_based import KMM
from sklearn.linear_model import LogisticRegression

np.random.seed(0)
Xs = np.random.randn(10, 2)
ys = np.random.choice(2, 10)

Xt = np.random.randn(10, 2)

model = KMM(LogisticRegression(), verbose=0)
model.fit(Xs, ys, Xt)

model.estimator_.predict_proba(Xt)

# array([[0.32728159, 0.67271841],
#        [0.46798244, 0.53201756],
#        [0.19779639, 0.80220361],
#        [0.37254084, 0.62745916],
#        [0.41436869, 0.58563131],
#        [0.32523053, 0.67476947],
#        [0.46625157, 0.53374843],
#        [0.48592336, 0.51407664],
#        [0.55101478, 0.44898522],
#        [0.5248281 , 0.4751719 ]])

@SrikrishnaBhat
Copy link
Author

Sorry, I forgot to respond back. This works and answers my question, thanks for the quick reply, I am closing this issue.

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

2 participants