Learning curve and validation curve sklearn

Viewed 1174

I'm new to machine learning, trying to use Neural Network to classify MNIST dataset

from sklearn.neural_network import MLPClassifier
from sklearn.datasets import fetch_openml
import matplotlib.pyplot as plt
import numpy as np

X, y = fetch_openml('mnist_784', return_X_y=True)
X_train, X_test = X[:60000], X[60000:]
y_train, y_test = y[:60000], y[60000:]

mlp = MLPClassifier(
                random_state=1,
                hidden_layer_sizes = (64,),
                activation = 'relu',
                solver = 'adam',
                learning_rate_init = 1e-3,
                alpha = 0,
                n_iter_no_change = 25,
                max_iter=500,
                )

mlp.fit(X_train, y_train)

fig, ax = plt.subplots(figsize=(6,4))
ax.plot(mlp.loss_curve_)
ax.set_xlabel('Number of iterations')
ax.set_ylabel('Loss')
plt.show()

This is the plot that I got from this code. graph 1 - X_train and y_train

I'm trying to plot another graph with X_test, y_test to plot a graph something like this: graph 2 - X_test and y_test

What do I need to do get the graph like 2nd image?

0 Answers
Related