Analyzing Iris Flower Data Set
- thecuriouslad
- Oct 4, 2019
- 2 min read
Updated: Oct 13, 2019
Iris Flower data set consists of 50 specimens from each of three species of Iris Flower(Iris setosa, Iris virginica and Iris versicolor). Four features were measured from each sample - the length and the width of the sepals and petals, in centimeters. We will find out if any correlation exists between these features that will help us predicting the species of the flower based on the features. The data set can be downloaded from here.
First, let us plot a Scatter Plot with Sepal Length as X-axis, Sepal Width as Y-axis and color code by Species to find out if we can find any correlation between them.
Python Code:

We can observe that even though Setosa is well distinguished from others, Versicolor and Virginica tend to overlap quite often. We can deduce that following sepal lengths and widths may not be accurate always
So, let us do scatter plot again but this time with petal lengths and widths.

Here, the plot is more distinguished. Given petal features of a flower, we can try to predict which species it belongs to. Iris Setosa has a very small petal area and Virginica has the largest petal area out of the three.
If we want to analyze plots between all features present, we can always use pair plot. Creating a pair is really easy. All it takes is a line of code and we have the below output.

And the line of code:
Notice how we used (hue = 'Species') in the pair plot as opposed to (hue = flower_data['Species']) in the Scatter plot above. This is because in the pair plot, we're taking the whole 'flower_data' data frame for plotting. But in Scatter plot, we're using only two columns. If we don't explicitly say (hue = flower_data['Species']) in the scatter plot, it wouldn't know where to look. But in the pair plot, we're taking the whole of the data set. So, we can just say 'Species' data set and it understands 'Species' must be a column in the flower_data data frame.
コメント