Project 2
PROJECT 2 SUMMARY :
This summary provides a comprehensive overview of the analysis steps. It highlights the data loading, cleaning, analysis techniques (correlation, regression, groupby), and key findings about wine quality, alcohol content, acidity, and color.
Data Acquisition and Exploration:
- Import Libraries: pandas (pd) and NumPy (np) are imported for data manipulation and numerical operations.
- Read Data: Red and white wine data are loaded from CSV files using pd.read_csv.
- Head: The first few rows of each dataset are displayed using .head().
- Data Size: The dimensions (number of rows and columns) of each dataset are printed.
- Null Values: The number of null values in each column is checked using .isnull().sum().
- Duplicates: Duplicates are removed from both datasets using .drop_duplicates().
- Unique Values: The number of unique values in each feature for both datasets is printed.
Data Cleaning and Preprocessing:
- Mean Density: The mean density of red and white wine is calculated using .mean().
- Combine Data: Both datasets are combined into a single DataFrame with a new column indicating wine color ('White' or 'Red').
- Handle Missing Values: Remaining null values (if any) are removed using .dropna().
- Outlier Removal: Outliers (data points significantly different from the rest) are removed using z-scores from SciPy.
Data Analysis:
- Alcohol-Quality Correlation: The correlation between alcohol content and quality rating is calculated using .corr().
- Citric Acid-pH Correlation: The correlation between citric acid content and pH is calculated using .corr().
- pH Regression on Citric Acid: Linear regression is performed to model pH based on citric acid using statsmodels.api.sm.
- Independent Variables: The number of independent variables is identified by analyzing correlation coefficients and excluding highly correlated features.
- Acidity Level: A new column for acidity level is created based on pH values using pd.cut and labeled with categories.
Further Analysis:
- Mean Quality by Acidity: The mean quality for each acidity level is calculated using groupby and .mean().
- Wine Color and Quality: The mean quality for red and white wines is compared using groupby and .mean().
- Low-Alcohol Samples: Samples with alcohol content below the median are selected.
- Quality by Alcohol Group: Mean quality for low- and high-alcohol groups is calculated.
- Residual Sugar and Quality: The correlation between residual sugar and quality is calculated using .corr().
- Quality Rating Counts: The number of samples with each quality rating for each wine color is counted using groupby and .size().
- Wine Density Similarity: The mean density and absolute difference in mean density for red and white wines are calculated.
- Confidence Interval: The confidence interval for the difference in the proportion of white wines with rating 3 and red wines with rating 3 is calculated using statsmodels.stats.proportion.