python报错:Invalid parameter alpha for estimator Pipeline

报错信息

Invalid parameter alpha for estimator Pipeline

解决办法:在pipe里定义的名称后要加两个下杠。

原始:

pipe = Pipeline([('scaler',StandardScaler()),
                    ('mlp',MLPClassifier(max_iter=1600,random_state = 38))])
params = {'mlp_hidden_layer_sizes':[(50,),(100,),(100,100)],
         'mlp_alpha':[0.0001,0.001,0.01,0.1]} #下片代码改成了两个下横杠

改正

pipe = Pipeline([('scaler',StandardScaler()),
                    ('mlp',MLPClassifier(max_iter=1600,random_state = 38))])
params = {'mlp__hidden_layer_sizes':[(50,),(100,),(100,100)],
         'mlp__alpha':[0.0001,0.001,0.01,0.1]} #注意两个mlp后都是两横下杠

你可能感兴趣的:(Python,报错)