4. Data Representation and Visualization of Data
By Bernd Klein. Last modified: 07 Jul 2022.
Machine learning is about adapting models to data. For this reason we begin by showing how data can be represented in order to be understood by the computer.
At the beginning of this chapter we quoted Tom Mitchell's definition of machine learning: "Well posed Learning Problem: A computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E." Data is the "raw material" for machine learning. It learns from data. In Mitchell's definition, "data" is hidden behind the terms "experience E" and "performance measure P". As mentioned earlier, we need labeled data to learn and test our algorithm.
However, it is recommended that you familiarize yourself with your data before you begin training your classifier.
Numpy offers ideal data structures to represent your data and Matplotlib offers great possibilities for visualizing your data.
In the following, we want to show how to do this using the data in the sklearn module.
Iris Dataset, "Hello World" of Machine Learning
What was the first program you saw? I bet it might have been a program giving out "Hello World" in some programming language. Most likely I'm right. Almost every introductory book or tutorial on programming starts with such a program. It's a tradition that goes back to the 1968 book "The C Programming Language" by Brian Kernighan and Dennis Ritchie!
The likelihood that the first dataset you will see in an introductory tutorial on machine learning will be the "Iris dataset" is similarly high. The Iris dataset contains the measurements of 150 iris flowers from 3 different species:
- Iris-Setosa,
- Iris-Versicolor, and
- Iris-Virginica.
Iris Setosa

Iris Versicolor

Iris Virginica

The iris dataset is often used for its simplicity. This dataset is contained in scikit-learn, but before we have a deeper look into the Iris dataset we will look at the other datasets available in scikit-learn.
Live Python training
See our Python training courses
Loading the Iris Data with Scikit-learn
For example, scikit-learn has a very straightforward set of data on these iris species. The data consist of the following:
