Skip to main content
 首页 » 编程设计

python之类型错误 : MLPClassifier() got an unexpected keyword argument 'algorithm'

2024年10月24日10kenshinobiy

我刚刚安装了 scikit-learn v0.18 开发包。

当我在 iPython 上调用以下代码时;

>>> from sklearn.neural_network import MLPClassifier 
>>> clf = MLPClassifier(algorithm='l-bfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1) 

没有错误。但是当我编写一个 python 脚本文件并在其上运行代码时,出现以下错误:

clf = MLPClassifier(algorithm='l-bfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1, warm_start=True) 
TypeError: MLPClassifier() got an unexpected keyword argument 'algorithm' 

不知道哪里出了问题。我该如何修复这个错误?

请您参考如下方法:

您需要将 algorithm 参数更改为 solver。查看documentation for that estimator和 repo for dev .