JZ0
JZ0

Reputation: 81

Plot training and validation accuracy and loss

I am new to Python and trying to plot the training and validation accuracy and loss for my MLP Regressor, however, I am getting the following error, what am I doing wrong?

TypeError: fit() got an unexpected keyword argument 'validation_split'

mlp_new = MLPRegressor(hidden_layer_sizes=(18, 18,18),
                       max_iter = 10000000000,activation = 'relu',
                       solver = 'adam', learning_rate='constant', 
                       alpha=0.05,validation_fraction=0.2,random_state=0,early_stopping=True)

mlp_new.fit(X_train, y_train)
mlp_new_y_predict = mlp_new.predict((X_test))
mlp_new_y_predict

import keras
from matplotlib import pyplot as plt
history = mlp_new.fit(X_train, y_train, validation_split = 0.1, epochs=50, batch_size=4)
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'val'], loc='upper left')
plt.show()

Upvotes: 1

Views: 1505

Answers (1)

mz2300
mz2300

Reputation: 524

Yes, you definitely can find a validation_split arg in the keras model .fit() method. But: The model you are going to use here is not that one.

Check the documentation below, Methods section: method .fit(..) has only two args: X and y.

https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPRegressor.html#sklearn.neural_network.MLPRegressor.fit

Upvotes: 1

Related Questions