def trainMLP(X_train, y_train):
model_mlp = MLPRegressor(
hidden_layer_sizes=(20, 1), activation='logistic', solver='adam', alpha=0.0001, batch_size='auto',
learning_rate='constant', learning_rate_init=0.001, power_t=0.5, max_iter=5000, shuffle=True,
random_state=1, tol=0.0001, verbose=False, warm_start=False, momentum=0.9, nesterovs_momentum=True,
early_stopping=False, beta_1=0.9, beta_2=0.999, epsilon=1e-08)
model_mlp.fit(X_train, y_train)
return model_mlp
如代码清单2所示,该模型的超参数较多,最重要的几个超参数为hidden_layer_sizes(隐藏层神经元个数,在本次实验当中隐藏层分别为5和1),activations(激活函数,可以选择relu、logistic、tanh等),solver(优化方法,即sgd、adam等),以及与优化方法相关的learning_rate(学习率),momentum(动量)等,设置完模型参数后,使用fit函数完