Home>

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?

  • Answer # 1

      

    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 leftaxmeans that such a keyword argument is inmglearn.discrete_scatter (). Theaxon 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

  • Answer # 2

    self-solved.
    The first argument indicates the X value on the graph, and the second argument indicates the Y value on the graph.
    The third argument is not y, but the same graph is shown even if it is 1.
    It seems that it was a command about the setting on the graph.

    Addition:
    I looked at only the correction request, and quickly picked it up and solved it by google, but I got the answer below.
    I rushed to resolve myself, but the content of the person who answered was more accurate than the content of my self solution. .
    I would like to deepen my understanding by reading the answers.
    Thank you for this time.