Visualizing the dataset

We can plot these data points in a scatter plot using Matplotlib. Here, the idea is to plot the x values (found in the first column of X, X[:, 0]) against the y values (found in the second column of X, X[:, 1]). A neat trick is to pass the target labels as color values (c=y):

In [3]: import matplotlib.pyplot as plt
... %matplotlib inline
... plt.scatter(X[:, 0], X[:, 1], c=y, s=100)
... plt.xlabel('x values')
... plt.ylabel('y values')
Out[3]: <matplotlib.text.Text at 0x24f7ffb00f0>

This will produce the following output:

The preceding output shows the randomly generated data for a binary classification problem. You can see that, for the most part, data points of the two classes are clearly separated. However, there are a few regions (particularly near the left and bottom of the plot) where the data points of both classes intermingle. These will be hard to classify correctly, as we will see in just a second.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.77.63