ageron / ageron/handson-ml

numpy permutation issue

Open
#394 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
25.6k
Forks
12.7k
PR merge metrics
No merged PRs in 30d

Description

Hi, I just want to understand the rules of the permutation used in numpy
see this is the code used in example2

```
import numpy as np

shuffle_index = np.random.permutation(60000)
X_train, y_train = X_train[shuffle_index], y_train[shuffle_index]
```

well, let us use 6 instead of 60000. So after run the 1st code, the `shuffle_index` could be:
[4,5,2,6,3,1], it is an array, right?

then I can not understand the `X_train[shuffle_index]`, so it is what? `X_train[[4,5,2,6,3,1]]`, I guess we want the `X_train` can be ordered as `X_train[4], X_train[5], X_train[2]...`. but this can be done by `X_train[shuffle_index]`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.