Closed Iovus closed 3 years ago
Hi lovus,
I got the same issue.
I found out the "mnist.data
" is not numpy array as in the book anymore. The "mnist.data
" is a dataframe object
I just added one line to convert the dataframe to numpy, and it works just like in the book.
This is the sort_by_target function that works for me:
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 = mnist.data.to_numpy()
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]
2021-1-23 Python 3.7.6 Numpy 1.19.5 Scikit-learn 0.24.1
Thank you!
Thanks for your feedback everyone!
So here's the deal: in Scikit-Learn 0.24, the fetch_openml()
function started returning Pandas DataFrames instead of NumPy arrays. This was causing various errors in the notebooks that used fetch_openml()
. This is why you ran into an issue, I'm sorry about that. I updated all the notebooks to set as_frame=False
when calling fetch_openml()
, and now everything's back to normal. You can get the latest code using git pull
, and make sure to install the latest version of the libraries as well (using environment.yml
or requirements.txt
).
Closing this issue. Please feel free to reopen it if the problem persists.
Hope this helps!
Hi, I got the issue that "sort_by_target" cannot be executed on the MNIST dataset. So far I cannot solve the problem.
Help is appreciated :)
Python 3.8.5 NUMPY version is 1.19.4. Scikit-learn version is 0.24.0.
Utilizing the code for "sort_by_target" from the chapter 3 repository I got the following error message:
KeyError Traceback (most recent call last)