Skip to content

AttributeError: 'NeuralNetClassifier' object has no attribute 'decision_function' #1003

Answered by BenjaminBossan
Centrattic asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, I converted your issue to a discussion, I hope you don't mind.

There is a fix for your problem, which is to pass the classes argument to your net. So e.g. for binary classification:

net = NeuralNetClassifier(..., classes=np.array([0, 1]))

For your specific problem, replace np.array([0, 1]) with the (label-encoded) classes of your task.

To explain the error: AUC needs to know all existing classes. So it asks the net for the classes_ attribute. Since the net was fitted with y=None, it does not know the classes, so it tries to infer it with classes_inferred_. This in turn tries to extract the y from the dataset, but that only works for some types of dataset. In your case, it didn't work,…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Centrattic
Comment options

Answer selected by BenjaminBossan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1002 on August 02, 2023 10:25.