what is dataset xdata and ydata. why we are plotting xdata along both the axes X and Y and not plotting Y values on Y-axis. why is Y defining the class 0 an 1 on what basis.
K-nearest neighbour
Hey @shekhar8110, if your X has two features lets say X denotes dog name and lets say bruno the labra dog(a point in some space) has 2 features-(height and weight). Now for seeing where the point lies in the space we are plotting X[:,0] AND X[:,1]. Its just like plotting x and y for a line’s equation where a line has two variable features x and y for the equation y-mx+c=0. So just like that x[:,0]=x and x[:,1]=y. SO we are plotting these.
Similarly there is another dog named ‘musk’ and he is of ‘husky’, so we will be plotting it as well on the same graph.
Similarly when you pass c = y than each point individually recieved 0 or 1 as its color. plt.scatter itself assigns color encoding meaning say it assigned 0 as yellow and 1 as blue than each point which has y=0 will be shown on graph using yellow color and those with y=1 will be shown using blue color. So now lebra dog will be shown with different colour and huskies in different colour.
HOpe this resolved your doubt.
Plz mark the doubt as resolve in my doubts section. 