AttributeError:"MLPClassifier"对象没有属性"decision_function" [英] AttributeError: 'MLPClassifier' object has no attribute 'decision_function'
问题描述
我不知道为什么在尝试使用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)
我也使用DecisionTreeClassifier()
推荐答案
尽管BaggingClassifier确实具有decision_function
方法,但只有在选择的base_estimator也支持该方法的情况下,该方法才有效. MLPClassifier
不.另一方面,某些模型(例如SVM和逻辑回归)可以形成超平面.如果您对预测的信心感兴趣,可以考虑将predict_proba
方法用作相关度量;否则,请执行以下步骤.它们完全不同( 1 , 2 ).
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).
这篇关于AttributeError:"MLPClassifier"对象没有属性"decision_function"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!