| π | π | π¬ | π | π οΈ |
|---|---|---|---|---|
| Overview | Architecture | Pipeline | Visuals | Run It |
Raw data is messy. Good models need clean data. This project walks through a complete Exploratory Data Analysis (EDA), Data Cleaning, and Preprocessing workflow, turning a raw dataset into a reliable, analysis-ready one.
ββββββββββββββββββββββββββββββββββββββββββββ
β±β RAW DATA β CLEAN DATA β INSIGHTS ββ²
β± ββββββββββββββββββββββββββββββββββββββββββββ β²
β± ββββββββββββββββββββββββββββββββββββββββββ β²
β±____βββββββββββββββββββββββββββββββββββββββββ_____β²
β²ββββββββββββββββββββββββββββββββββββββββββββββββββββ±
β²___________ DATA QUALITY LAYER ___________β±
- π₯ Loading and inspecting the dataset
- π§± Understanding structure, dimensions, and data types
- π©Ή Handling missing values and checking data quality
- π Descriptive statistics for key features
- π Distributions with histograms and count plots
- π¨ Outlier detection using boxplots
- π Exploring relationships and patterns
- π€ Preparing the dataset for machine learning
Click-free, rendered natively by GitHub (Mermaid):
flowchart LR
A[(π Raw Dataset<br/>CSV / Excel)] --> B[π₯ Load & Inspect<br/>head, info, shape]
B --> C[π§± Understand Structure<br/>dtypes, dimensions]
C --> D{π©Ή Missing Values?}
D -- Yes --> E[π§ Impute / Drop]
D -- No --> F
E --> F[π Descriptive Stats<br/>describe, value_counts]
F --> G[π Univariate Analysis<br/>hist, countplot]
G --> H[π¨ Outlier Detection<br/>boxplot, IQR]
H --> I[π Bivariate / Multivariate<br/>heatmap, pairplot]
I --> J[βοΈ Preprocessing<br/>encode, scale]
J --> K[(β
Clean Dataset<br/>ML-Ready)]
style A fill:#ff7675,stroke:#d63031,color:#fff
style K fill:#00b894,stroke:#00695c,color:#fff
style D fill:#fdcb6e,stroke:#e17055,color:#000
style H fill:#e17055,stroke:#d63031,color:#fff
β±βββββββββββββββββββββββββββ²
β± LAYER 5 Β· ML-READY DATA β² β Output
β±βββββββββββββββββββββββββββββββ²
β± LAYER 4 Β· PREPROCESSING β² β Encode, scale
β±βββββββββββββββββββββββββββββββββββ²
β± LAYER 3 Β· VISUAL EXPLORATION β² β Plots, outliers
β±βββββββββββββββββββββββββββββββββββββββ²
β± LAYER 2 Β· CLEANING & QUALITY CHECKS β² β Missing, duplicates
β±βββββββββββββββββββββββββββββββββββββββββββ²
β LAYER 1 Β· RAW DATA INGESTION β β Load & inspect
ββββββββββββββββββββββββββββββββββββββββββββ
π₯ Step 1 Β· Load & Inspect the Data
Goal: Get a first feel for the dataset.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv("data/dataset.csv")
df.head() # first look
df.tail() # last rows
df.sample(5) # random peekπ‘ Why it matters: You can't fix what you haven't seen.
π§± Step 2 Β· Understand Structure, Dimensions & Data Types
print("Shape:", df.shape)
df.info()
print(df.dtypes)
print(df.columns.tolist())| Check | Tells you |
|---|---|
df.shape |
Rows Γ columns |
df.info() |
Non-null counts, dtypes, memory |
df.dtypes |
Numeric vs categorical vs date |
object, dates stored as strings.
π©Ή Step 3 Β· Missing Values & Data Quality
# Count and percentage of missing values
missing = df.isnull().sum()
missing_pct = (missing / len(df) * 100).round(2)
print(pd.DataFrame({"Missing": missing, "Percent": missing_pct}))
# Visualize missingness
sns.heatmap(df.isnull(), cbar=False, cmap="viridis")
plt.title("Missing Value Map")
plt.show()
# Duplicates
print("Duplicates:", df.duplicated().sum())
df = df.drop_duplicates()Common strategies
| Situation | Strategy |
|---|---|
| Numeric, roughly symmetric | Fill with mean |
| Numeric, skewed | Fill with median |
| Categorical | Fill with mode |
| Too many missing (>40β50%) | Consider dropping the column |
df["numeric_col"] = df["numeric_col"].fillna(df["numeric_col"].median())
df["category_col"] = df["category_col"].fillna(df["category_col"].mode()[0])π Step 4 Β· Descriptive Statistics
df.describe() # numeric summary
df.describe(include="object") # categorical summary
df["category_col"].value_counts()
df.skew(numeric_only=True) # distribution shapeπ§ Look at the gap between mean and median. A big gap hints at skew or outliers.
π Step 5 Β· Distributions (Histograms & Count Plots)
# Numeric features
df.hist(figsize=(14, 10), bins=30, edgecolor="black")
plt.tight_layout()
plt.show()
# Categorical features
plt.figure(figsize=(8, 5))
sns.countplot(data=df, x="category_col", palette="viridis")
plt.xticks(rotation=45)
plt.show()| Plot | Best for |
|---|---|
| Histogram | Shape of numeric data |
| KDE plot | Smooth distribution |
| Count plot | Category frequency / imbalance |
π¨ Step 6 Β· Outlier Detection (Boxplots + IQR)
sns.boxplot(x=df["numeric_col"], color="skyblue")
plt.show()
# IQR method
Q1 = df["numeric_col"].quantile(0.25)
Q3 = df["numeric_col"].quantile(0.75)
IQR = Q3 - Q1
lower, upper = Q1 - 1.5 * IQR, Q3 + 1.5 * IQR
outliers = df[(df["numeric_col"] < lower) | (df["numeric_col"] > upper)]
print(f"Outliers found: {len(outliers)}") ββββββββββ€βββββββββββββββββββββββββββββ€ β β
lower Q1 median Q3 upper outliers
whisker whisker
Options: keep (if real), cap/winsorize, transform (log), or remove (if errors).
π Step 7 Β· Relationships & Patterns
# Correlation heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(df.corr(numeric_only=True), annot=True, cmap="coolwarm", fmt=".2f")
plt.title("Correlation Matrix")
plt.show()
# Pairwise relationships
sns.pairplot(df, hue="target_col")
plt.show()
# Numeric vs category
sns.boxplot(data=df, x="category_col", y="numeric_col")
plt.show()βοΈ Step 8 Β· Prepare for Machine Learning
from sklearn.preprocessing import LabelEncoder, StandardScaler
# Encode categoricals
df = pd.get_dummies(df, columns=["category_col"], drop_first=True)
# Scale numerics
scaler = StandardScaler()
num_cols = df.select_dtypes(include="number").columns
df[num_cols] = scaler.fit_transform(df[num_cols])
# Save the clean dataset
df.to_csv("data/cleaned_dataset.csv", index=False)β Output: a clean, encoded, scaled dataset ready for modeling.
Replace the placeholders below with screenshots from your notebook (save them in an
assets/folder).
| π Histogram | π¦ Boxplot | π₯ Heatmap |
|---|---|---|
![]() |
![]() |
![]() |
π₯ Demo: add your screen recording link here β [Watch Walkthrough](https://your-video-link)
| Metric | π΄ Raw Data | π’ Cleaned Data |
|---|---|---|
| Missing values | x | 0 |
| Duplicate rows | x | 0 |
| Outliers flagged | x | handled |
| Data types | inconsistent | fixed |
| ML-ready | β | β |
π¦ eda-data-cleaning-preprocessing
β£ π data
β β£ π dataset.csv
β β π cleaned_dataset.csv
β£ π notebooks
β β π EDA_and_Preprocessing.ipynb
β£ π assets
β β£ πΌοΈ histogram.png
β β£ πΌοΈ boxplot.png
β β πΌοΈ heatmap.png
β£ π requirements.txt
β π README.md
# 1οΈβ£ Clone the repository
git clone https://github.com/<your-username>/<your-repo>.git
cd <your-repo>
# 2οΈβ£ (Optional) Create a virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3οΈβ£ Install dependencies
pip install -r requirements.txt
# 4οΈβ£ Launch Jupyter
jupyter notebookrequirements.txt
pandas
numpy
matplotlib
seaborn
scikit-learn
jupyter
- π§Ή Clean data > fancy models. Most ML problems start as data problems.
- π Visualize early. Plots reveal what summary statistics hide.
- π§ͺ Document every decision. Why you imputed, capped, or dropped matters.
- π EDA is iterative. You'll revisit earlier steps as you learn more.
- Automated profiling with
ydata-profiling - Interactive plots with Plotly
- Feature engineering & selection
- Baseline ML model on the cleaned data
- Streamlit dashboard for live exploration


