1

我正在尝试将 MLPRegressor 用于多变量回归问题。我想知道如何在训练时查看是否存在过拟合?

我可以使用 访问训练损失loss_curve_和验证分数validation_scores_,但我希望看到类似这样的验证损失:

在此处输入图像描述

我的代码如下:

x_train = x_train[0:50000,:]
y_train = y_train[0:50000,:]
x_test = x_test[0:10000,:]
y_test = y_test[0:10000,:]
x_train = x_train[0:50000,:]
y_train = y_train[0:50000,:]
x_test = x_test[0:10000,:]
y_test = y_test[0:10000,:]

prediction=MLPRegressor(hidden_layer_sizes=(50,50), activation='relu', solver='adam', alpha=0.0001, batch_size=1000,
                    learning_rate='adaptive', learning_rate_init=0.001, power_t=0.5, max_iter=200,
                    shuffle=True, random_state=None, tol=0.0001, verbose=10, warm_start=True,
                    momentum=0.9, nesterovs_momentum=True, early_stopping=True, validation_fraction=0.2,
                    beta_1=0.9, beta_2=0.999, epsilon=1e-08, n_iter_no_change=100)



prediction.fit(x_train, y_train)

fig = plt.figure()
ax = fig.add_subplot(111)
plt.ylabel('Training Loss')
plt.xlabel('Iterations')
ax.plot(pd.DataFrame(prediction.loss_curve_))
fig.savefig('/home/sagnik/machineLearning/results/loss_curve_.png')

fig = plt.figure()
ax = fig.add_subplot(111)
plt.ylabel('Validation Score')
plt.xlabel('Iterations')
ax.plot(pd.DataFrame(prediction.validation_scores_))
fig.savefig('/home/sagnik/machineLearning/results/validation_scores_.png')
4

0 回答 0