scikit learn 0.18.1:' module'对象没有属性' neural_network'

时间:2017-03-19 00:29:19

标签: python scikit-learn

您好我正在尝试使用MLP

import numpy as np
import sklearn as sk

X = [[0., 0.], [1., 1.]]

Y = [[1.1, 1.1], [2.1, 2.1]]

reg = sk.neural_network.MLPRegressor(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)

我认为神经网络可用于0.18.1,但我收到以下错误:

AttributeError: 'module' object has no attribute 'neural_network'

1 个答案:

答案 0 :(得分:2)

使用此类导入:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/js/bootstrap-switch.js" data-turbolinks-track="true"></script>

并为此调整您的剩余代码:

from sklearn.neural_network import MLPClassifier

考虑阅读Modules上的python doc。