OK 400
OK 400

Reputation: 831

AttributeError: 'MLPClassifier' object has no attribute 'decision_function'

I do not know why I'm getting that error while I'm trying to use decision_function()

model_1 = BaggingClassifier(base_estimator=MLPClassifier())
model_1.fit(Xtrain, ytrain)
model_1.decision_function(Xtrain)

I'm also getting that error using DecisionTreeClassifier()

Upvotes: 4

Views: 4759

Answers (1)

Reveille
Reveille

Reputation: 4619

Although BaggingClassifier does have the decision_function method, it would only work if the base_estimator selected also supports that method; MLPClassifier does not. Some models like SVM and logistic regression, which form hyperplanes, on the other hand, do. If you are interested in the confidence in predictions, you may consider the predict_proba method as a related measure; they are not at all the same though (1, 2).

Upvotes: 7

Related Questions