I am trying to use a MLPRegressor for multi-variate regression problem. I want to know how can I see if there is overfitting while training?
I am able to access the training loss loss_curve_
and the validation scores using validation_scores_
, but I want to see something like this with the validation loss:
My code is as follows:
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')