Plot the Data Points

Learn how digits are formed by plotting some of the data points.

Code to plot data points

We saw earlier how we might plot a rectangular array of numbers using the imshow() function. We want to do the same here, but we need to convert that list of comma-separated numbers into a suitable array. Here are the steps to do that:

  1. Split that long text string of comma-separated values into individual values, using the commas as the place to do the splitting.

  2. Ignore the first value and the label, and take the remaining list of 28×28=78428 \times 28 = 784 values and turn them into an array that has a shape of 2828 rows ×\times 2828 columns.

  3. Plot that array.

Again, it is easiest to show the simple Python code that does this and talk through the code to explain in more detail what is happening.

We must not forget to import the Python extension libraries first, which will help us with arrays and plotting:

Get hands-on with 1200+ tech skills courses.