I did not understand the whole code.
def sort_by_target(mnist):
reorder_train = np.array(sorted([(target, i) for i, target in enumerate(mnist.target[:60000])]))[:, 1]
reorder_test = np.array(sorted([(target, i) for i, target in enumerate(mnist.target[60000:])]))[:, 1]
mnist.data[:60000] = mnist.data[reorder_train]
mnist.target[:60000] = mnist.target[reorder_train]
mnist.data[60000:] = mnist.data[reorder_test + 60000]
mnist.target[60000:] = mnist.target[reorder_test + 60000]
from sklearn.datasets import fetch_openml
import numpy as np
mnist = fetch_openml(‘mnist_784’, version=1, cache=True)
mnist.target = mnist.target.astype(np.int8)
sort_by_target(mnist)
X, y = mnist[“data”], mnist[“target”]
X.shape
y.shape
Please help me to understand.
Please reply