<jupyter_start><jupyter_text>Wine Data Univariate Analysis The dataset are related to red and white variants of the "Vinho Verde" wine. Vinho verde is a unique product from the Minho (northwest) region of Portugal. Medium in alcohol, is it particularly appreciated due to its freshness (specially in the summer).     1 - fixed acidity     2 - volatile acidity     3 - citric acid     4 - residual sugar     5 - chlorides     6 - free sulfur dioxide     7 - total sulfur dioxide     8 - density     9 - pH     10 - sulphates     11 - alcohol Output variable (based on sensory data):     12 - quality (score between 0 and 10)<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv("Wine_data.csv")
df.head(3)
df.shape
df.describe()
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 4898 entries, 0 to 4897
Data columns (total 12 columns):
 #   Column                Non-Null Count  Dtype  
---  ------                --------------  -----  
 0   fixed acidity         4898 non-null   float64
 1   volatile acidity      4898 non-null   float64
 2   citric acid           4898 non-null   float64
 3   residual sugar        4898 non-null   float64
 4   chlorides             4898 non-null   float64
 5   free sulfur dioxide   4898 non-null   float64
 6   total sulfur dioxide  4898 non-null   float64
 7   density               4898 non-null   float64
 8   pH                    4898 non-null   float64
 9   sulphates             4898 non-null   float64
 10  alcohol               4898 non-null   float64
 11  quality               4898 non-null   int64  
dtypes: float64(11), int64(1)
memory usage: 459.3 KB<jupyter_text>Univariate Analysis for Quantitative<jupyter_code>fig, ax=plt.subplots(2,1,figsize=(12,10))
sns.kdeplot(data=df, shade=True,ax=ax[0])
sns.distplot(df['fixed acidity'], hist = False, color ='magenta', kde_kws = {'shade':True}, ax=ax[1])
plt.show()<jupyter_output>C:\Users\<NAME>\anaconda3\lib\site-packages\seaborn\distributions.py:690: UserWarning: Passing a 2D dataset for a bivariate plot is deprecated in favor of kdeplot(x, y), and it will cause an error in future versions. Please update your code.
  warnings.warn(warn_msg, UserWarning)<jupyter_text>**Observations**- The kde plot of fixed scidity data which is right skewed and peakness is leptokurtic. **Create a box plot for (quality,fixed acidity,volatile acidity,citric acid,free sulfur dioxide,sulphates,density). Infer about your Overall Observations**<jupyter_code>fig, ax = plt.subplots(2,3,figsize=(10,8))
sns.boxplot(df['quality'],ax=ax[0,0])
sns.boxplot(df['fixed acidity'],ax=ax[0,1])
sns.boxplot(df['volatile acidity'],ax=ax[0,2])
sns.boxplot(df['citric acid'],ax=ax[1,0])
sns.boxplot(df['free sulfur dioxide'],ax=ax[1,1])
sns.boxplot(df['sulphates'],ax=ax[1,2])
plt.show()<jupyter_output><empty_output><jupyter_text>**Overall Oberservations**- Quality data has a few outliers beyond both highest value and lowest value.- fixed acidity data has outliers beyond both highest value and lowest value.- volatile acidity data has outliers only beyond highest value.- citric acid data has outliers beyond both highest and lowest value.- free sulfur dioxide data has outliers beyond highest value.- total sulfur dioxide data has outliers beyond highest value.- sulphates data has outliers beyond highest value.-  density data has a few outliers beyond highest value. **Analyse the quality using bar chart and Pie chart.**<jupyter_code>sns.countplot(df['quality'])
plt.show()<jupyter_output><empty_output><jupyter_text>**Observation**- Majority of the score are between 5,6 and 7.  Skeweness We will create a numeric feature to remove the skeweness of the data<jupyter_code>skeweness = [df['fixed acidity'].skew(),df['volatile acidity'].skew(),df['citric acid'].skew(),df['residual sugar'].skew(),
           df['chlorides'].skew(),df['free sulfur dioxide'].skew(),df['total sulfur dioxide'].skew(),
           df['density'].skew(),df['pH'].skew(),df['sulphates'].skew(),df['alcohol'].skew(),df['quality'].skew()]
columns = df.columns
skewed_df = pd.DataFrame({'columns':columns,'skeweness':skeweness})
skewed_df<jupyter_output><empty_output><jupyter_text>Get only higest skewed features<jupyter_code>skewed_df[skewed_df['skeweness'] == skewed_df['skeweness'].max()]<jupyter_output><empty_output><jupyter_text>Taking out skewed feature in another DataFrame<jupyter_code>skewed_features = skewed_df[abs(skewed_df['skeweness']) > 0.7]<jupyter_output><empty_output><jupyter_text>Create new DataFrame for skewed_features2 (chlorides)<jupyter_code>skewed_features2 = pd.DataFrame({'chlorides': df['chlorides']})
skewed_features2['log_chlorides'] = np.log(skewed_features2['chlorides'])
skewed_features2.head(3)<jupyter_output><empty_output><jupyter_text>**Verify using boxplot whether the skewness has been reduce or not. Write your observations**<jupyter_code>fig2, ax = plt.subplots(1,2)
sns.boxplot(skewed_features2['chlorides'],ax=ax[0])
sns.boxplot(skewed_features2['log_chlorides'],ax=ax[1])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1179236043095005, 'fraction_numerical': 0.034280117531831536, 'mean_word_length': 4.525974025974026, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '439764', 'license': 'MIT', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1621, 'n_words': 463, 'path': 'Univariate Analysis/Wine-Data Univariate Analysis-Revision-Part 1 and 2.ipynb', 'repo_name': 'Sarthak-GitHub/Ecploratory-Data-Analysis-on-Different-Datasets', 'size': '5113'}