N_CLASSES = np.unique(y_train) scores_train = [] scores_test = [] # EPOCH epoch = 0 while epoch < N_EPOCHS: print('epoch: ', epoch) # SHUFFLING random_perm = np.random.permutation(X_train.shape[0]) mini_batch_index = 0 while True: # MINI-BATCH indices = random_perm[mini_batch_index:mini_batch_index + N_BATCH] clf.partial_fit(X_train[indices], y_train[indices], classes=N_CLASSES) mini_batch_index += N_BATCH if mini_batch_index >= N_TRAIN_SAMPLES: break # SCORE TRAIN scores_train.append(clf.score(X_train, y_train)) # SCORE TEST scores_test.append(clf.score(X_test, y_test)) epoch += 1 plt.figure() plt.plot(scores_train, color='b', alpha=0.8, label='Train') plt.plot(scores_test, color='r', alpha=0.8, label='Test')