question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] AttributeError: 'GroupedPredictor' object has no attribute 'predict_proba'

See original GitHub issue

I am not sure if it’s me that I am not using correctly the API.

When doing a classification problem and using a GroupedPredictor to estimate probabilities I can’t get the probabilities

from sklego.meta import GroupedPredictor
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklego.datasets import load_chicken

df = load_chicken(as_frame=True)

# Create a binary target
X = df.drop(columns='weight')
y = np.where(df.weight>df.weight.mean(),1,0)

mod = GroupedPredictor(LogisticRegression(), groups=["diet"])

mod.fit(X,y)

mod.predict_proba(X)

Traceback (most recent call last): File "bug.py", line 25, in <module> mod.predict_proba(X) AttributeError: 'GroupedPredictor' object has no attribute 'predict_proba'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
skylarbpaynecommented, Aug 13, 2022

This can be closed, right?

0reactions
cmougancommented, Jan 23, 2021

It might be the case that since our GroupedPredictor needs to support both regression and classification that we didn’t implement predict_proba. Can you confirm that predict does work?

I do confirm that in this exact code, if you change mod.predict_proba, by mod. predict you get an output

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'Sequential' object has no attribute 'predict_proba'
predict_proba returns the error in the neural network.
Read more >
'sequential' object has no attribute 'predict_proba' - You.com
I ran into an error message <'History' object has no attribute 'predict'> when trying to run the code down. Y_predict = model.predict(X_test).reshape ...
Read more >
'CustomScaler' object has no attribute 'predict_proba'
Hi dear 365 team,. i downloaded and executed the modules like shown, but i am getting Attribute Error when i try to:.
Read more >
[Scikit-learn-general] Ovr Classifier predict error
Hello, I see an issue with predict in case of predicting a text document. [I load an already trained classifier (OneVsRest(SGDClassifier(loss=log))) using
Read more >
AttributeError: 'dict' object has no attribute 'predict_proba'
I try all versions, Windows/Ubuntu and a virtualenv. Nothing works! ... hi @joicepreuss - what command are you running that makes this error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found