In [ ]:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
In [ ]:
df= pd.read_csv('mushroom.csv')
df.head()
Out[ ]:
class cap-shape cap-color stem-height stem-width habitat season
0 p x o 16.95 17.09 d w
1 p x o 17.99 18.19 d u
2 p x o 17.80 17.74 d w
3 p f e 15.77 15.98 d w
4 p x o 16.53 17.20 d w
In [ ]:
#1. histplot
plt.figure(figsize=(5,3))
sns.countplot(data= df, x='class', hue= 'class', palette={'p':'red', 'e':'green'})
plt.title('Class Distribution')
plt.xlabel('Class')
plt.show()
No description has been provided for this image
In [ ]:
# 2 realtionship between stem height and width
plt.figure(figsize=(8,4))
sns.jointplot(data=df, x='stem-height', y='stem-width', kind='reg')
plt.show()
<Figure size 800x400 with 0 Axes>
No description has been provided for this image
In [ ]:
#3 edible and poisonous mushrooms are distribution among the
#distribution stem height and stem width
plt.figure(figsize=(6,5))
sns.scatterplot(data=df, x='stem-height', y='stem-width', hue='class',
                palette={'p':'red', 'e':'green'}, marker='x', s=50)
plt.show()
No description has been provided for this image

there's a strong positive correlation showing that edible mushrooms tend to be longer and thicker, and vice versa with non edible mushrooms.

In [ ]:
#4 stem height distributed across season using kde plot
plt.figure(figsize=(5,3))
sns.kdeplot(data=df, x='stem-height',hue= 'season', fill=True)
plt.show()
No description has been provided for this image
In [ ]:
# 5 visualization of distribution of stem height
plt.figure(figsize=(5,3))
sns.histplot(data=df, x='stem-height', kde=True)
plt.show()
No description has been provided for this image
In [ ]:
#6 visualization of the median of stem height over variable 'class'
sns.catplot(data=df, y='stem-height', x='class', kind= 'box', hue= 'class',
            palette={'p':'red', 'e':'green'})
plt.grid(axis= 'y', linewidth=0.5, linestyle='--', color= 'blue')
plt.xticks(rotation=20)
plt.show()
No description has been provided for this image

the medians are about the same for both classes

In [ ]:
#7 visualization of stem height is distributed across habitat
plt.figure(figsize=(5,3))
sns.catplot(data=df, x='habitat', y='stem-height', kind='box', hue='habitat')
plt.grid(axis= 'y', linewidth=0.5, linestyle='--', color= 'blue')
plt.xticks(rotation=20)
plt.show()
<Figure size 500x300 with 0 Axes>
No description has been provided for this image
In [ ]: