Box plot and histogram study on iris data



Attribute Information about the dataset:

 Attribute Information: - & gt; sepal length in cm - & gt; sepal width in cm - & gt; petal length in cm - & gt; petal width in cm - & gt; class: Iris Setosa Iris Versicolour Iris Virginica Number of Instances: 150 Summary Statistics: Min Max Mean SD Class Correlation sepal length: 4.3 7.9 5.84 0.83 0.7826 sepal width: 2.0 4.4 3.05 0.43 -0.4194 petal length: 1.0 6.9 3.76 1.76 0.9490 (high! ) petal width: 0.1 2.5 1.20 0.76 0.9565 (high!) Class Distribution: 33.3% for each of 3 classes. 

To get iris data, click here .

Loading libraries

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

Loading data

data = pd.read_csv ( " Iris.csv " )

 

print < code class = "plain"> (data.head ( 10 ))

Exit:

Description

data.describe ()

Exit:

Information

data.info ()

Exit:

Code # 1: divider length histogram

plt.figure (figsize = ( 10 , 7 ))

x = data [ "SepalLengthCm" ]

 

plt.hist (x, bins = 20 , color = "green" )

plt.title ( "Sepal Length in cm" )

plt.xlabel ( "Sepal_Length_cm" )

plt.ylabel ( "Count" )

Exit:

Code no. 2: divider width histogram

plt.figure (figsize = ( 10 , 7 ))

x = data.SepalWidthCm

 

plt.hist (x, bins = 20 , color = "green" )

plt.title ( " Sepal Width in cm " )

plt.xlabel ( "Sepal_Width_cm" )

plt.ylabel ( "Count" )

 
plt.show ()

Output:

Code # 3: Petal length histogram

plt.figure (figsize = ( 10 , 7 ))

x = data.PetalLengthCm

 

plt.hist (x, bins = 20 , color = " green " )

plt.title ( "Petal Length in cm" )

plt.xlabel ( "Petal_Length_cm" )

plt.ylabel ( "Count" )

 
plt.show ()

Exit:

Code # 4: histogram for petal width

plt.figure (figsize = ( 10 , 7 ))

x = data.PetalWidthC m

 

plt.hist (x, bins = 20 , color = "green" )

plt.title ( "Petal Width in cm" )

plt.xlabel ( "Petal_Width_cm" )

plt.ylabel ( " Count " )

  
plt.show ()

Exit :

Code # 5:  Preparing data for the site

# remove column ID

new_data = data [[ "SepalLengthCm" , "SepalWidthCm" , "PetalLengthCm" , "PetalWidthCm" ]]

print (new_data.head ())

Output:

Code # 6: field for iris data

plt .figure (figsize = ( 10 , 7 ))

new_data.boxplot ()

Exit: