Violin area for data analysis

NumPy | Python Methods and Functions

Violin plots contain more information than boxed plots, they are less popular. Due to their unpopularity, their meaning may be more difficult to understand for many readers unfamiliar with the plot of the violin game.

To get a link to Iris Data, click here .

Attribute Dataset Information:

 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. 

Loading Libraries

import numpy as np

import pandas as pd

import seaborn as sns

from matplotlib import pyplot

import seaborn

Loading data

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

  

print (data.head ( 10 ))

Exit:

Description

data.describe ()

Exit :

Information

data.info ()

Exit :

Description of the SepalLengthCm parameter in the Iris dataset.

data [ "SepalLengthCm" ]. describe ()

Output:

 count 150.000000 mean 5.843333 std 0.828066 min 4.300000 25% 5.100000 50% 5.800000 75% 6.400000 max 7.900000 Name: SepalLengthCm, dtype: float64 

Code # 1: Violin section for the "SepalLengthCm" parameter.

fig, ax = pyplot.subplots (figsize = ( 9 , 7 ) )

sns.violinplot (ax = ax, y = data [ "SepalLengthCm" ])

Output:

As you can see we have a higher density between 5 and 6. This is very important because, as in the SepalLengthCm description, the average is 5.43.

Code # 2: Violin section for SepalLengthWidth.

 

fig, ax = pyplot.subplots (figsize = ( 9 , 7 ))

sns.violinplot (ax = ax, y = data [ "SepalWidthCm" ])

Exit:

Here also, Higher density on average = 3.05

Code # 3: Violin comparing "SepalLengthCm" and "SepalWidthC m ".

fig, ax = pyplot .subplots (figsize = ( 9 , 7 ))

sns.violinplot (ax = ax, data = data.iloc [:, 1 : 3 ])

Exit:

Code # 4: Violin area where the SepalLengthCm views are compared.

fig, ax = pyplot.subplots (figsize = ( 9 , 7 ))

sns.violinplot (ax = ax, x = data [ "Species" ], 

y = data [ "SepalLengthCm" ])

Exit:





Get Solution for free from DataCamp guru