Box Plots

Box plots are useful visualization for comparing the distributions

import matplotlib.pyplot as plt
from sklearn import datasets

Loading the datasets

iris = datasets.load_iris()
iris_df = pd.DataFrame(iris.data, columns=iris.feature_names)

decode_species = {0: 'Setosa', 1:'Versicolor', 2:'Virginica' }
iris_df['Species'] = [decode_species.get(specie) for specie in iris.target]
iris_df.head() 
sepal length (cm) sepal width (cm) petal length (cm) petal width (cm) Species
0 5.1 3.5 1.4 0.2 Setosa
1 4.9 3.0 1.4 0.2 Setosa
2 4.7 3.2 1.3 0.2 Setosa
3 4.6 3.1 1.5 0.2 Setosa
4 5.0 3.6 1.4 0.2 Setosa

Rendering the Box Plot

sns.boxplot(data=iris_df, y= 'sepal length (cm)', x='Species')
plt.title('Box and Whiskers Plot Sepal Length by Species')
Box Plot