In [ ]:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
In [ ]:
df=pd.read_csv('winequality.csv')
df.head()
Out[ ]:
fixed acidity volatile acidity citric acid residual sugar chlorides free sulfur dioxide total sulfur dioxide density pH sulphates alcohol quality
0 7.4 0.70 0.00 1.9 0.076 11.0 34.0 0.9978 3.51 0.56 9.4 5
1 7.8 0.88 0.00 2.6 0.098 25.0 67.0 0.9968 3.20 0.68 9.8 5
2 7.8 0.76 0.04 2.3 0.092 15.0 54.0 0.9970 3.26 0.65 9.8 5
3 11.2 0.28 0.56 1.9 0.075 17.0 60.0 0.9980 3.16 0.58 9.8 6
4 7.4 0.70 0.00 1.9 0.076 11.0 34.0 0.9978 3.51 0.56 9.4 5
In [ ]:
#check quality level distribution ()
plt.figure(figsize=(5,3))
sns.countplot(data= df, x='quality', hue= 'quality', palette= 'RdPu')
plt.show()
No description has been provided for this image
In [ ]:
plt.figure(figsize=(5,3))
sns.countplot(data= df, x='quality', hue= 'quality', palette= 'RdPu',
              stat= 'percent')
plt.show()
No description has been provided for this image
In [ ]:
#point plot- explore sulphate's central tendency and variance across quality
plt.figure(figsize=(5,3))
sns.pointplot(data= df, x= 'quality', y= 'sulphates', linestyle='--',
              marker='X', markersize= '15', color='hotpink', mfc='steelblue',
              mec='black')
plt.grid(axis= 'y', linewidth=0.5, linestyle='--', color= 'blue')
plt.show()
#plt.title('Sulphates vs Quality')
plt.show()#the bar is the variance
No description has been provided for this image
In [ ]:
#explore the average and variance of sulphates and volatile acidity across quality
plt.figure(figsize=(5,3))
sns.pointplot(data= df, x= 'quality', y= 'sulphates', linestyle='--',
              marker='X', markersize= '15', color='hotpink', mfc='steelblue',
              mec='black', label='sulphates')
sns.pointplot(data= df, x= 'quality', y= 'volatile acidity', linestyle='--',
              marker='o', markersize= '10', color='green', mfc='lightgreen',
              mec='black', label='volatile acidity')
plt.legend()
plt.grid(axis= 'y', linewidth=0.5, linestyle='--', color= 'blue')
plt.ylabel('value')
plt.show()
No description has been provided for this image
In [ ]:
plt.figure(figsize=(5,3))
sns.pointplot(data= df, x= 'quality',y='sulphates', errorbar=('pi', 100),
              color= 'hotpink', capsize=.2, linestyle= 'none', mec='skyblue',
              mfc='blue', markersize= 10)
#error bar=pi, the variance bar is stretched to the entire range
plt.grid(axis= 'y', linewidth=0.5, linestyle='--', color= 'blue')
plt.show()
No description has been provided for this image
In [ ]: