Home>

### about the python code discrete_scatter

mglearn.discrete_scatter (X [:, 0], X [:, 1], y, ax = ax)

Can you tell me the meaning of the above code in detail?
The first argument X [:, 0] represents the X axis, all values ​​of X and the y = 0 part,
Does the second argument X [:, 1] represent the y-axis and represents all values ​​of X and y = 1?
The third argument is the title, right? Is y the title?
Can the last ax = ax have the axis as a column?

`X [:, 0], X [:, 1]`

Each XY coordinate value. It ’s taken out in slices. This is the basic of numpy and should be remembered.

``````>>>import numpy as np
>>>a = np.array ([[1,2,3], [4,5,6]])
>>>a [0]
array ([1, 2, 3])
>>>a [1]
array ([4, 5, 6])
>>>a [:, 0]
array ([1, 4])
>>>a [:, 1]
array ([2, 5])
>>>a [:, 2]
array ([3, 6])``````

Third argument

What are the labels for each point? Why did you think it was a title? What information are you referring to?

`ax = ax`

The left`ax`means that such a keyword argument is in`mglearn.discrete_scatter ()`. The`ax`on the right is an object created externally.

As a specific operation, you can draw an instance of matplotlib axes by passing it.

Reference:
Python-discrete_scatter and legend in mglearn (99285) | StackOverflow
python-About the meaning of mglearn.discrete_scatter (X_train [:, 0], X_train [:, 1], y_train)-stack overflow