Skip to main content
Data ScienceBeginner14 min readUpdated March 2025

Exploratory Data Analysis (EDA)

EDA is how you get to know a dataset before modeling. Use summary statistics and visualizations to uncover distributions, relationships, outliers and data quality problems.

The Goals of EDA

Exploratory analysis answers practical questions before any model is trained:

  • What does each variable look like — range, shape, spread?
  • How much data is missing, and is it missing at random?
  • Are there outliers or impossible values?
  • Which variables relate to each other and to the target?

First Look at the Data

Start with shape, types, and summary statistics:

python
import pandas as pd

df = pd.read_csv("housing.csv")

print(df.shape)
print(df.dtypes)
print(df.describe(include="all").T)

# Missing values as a percentage
print((df.isna().mean() * 100).round(1).sort_values(ascending=False))

Distributions and Outliers

Histograms and box plots show shape and unusual points. Skewed variables often benefit from a log transform:

python
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

fig, axes = plt.subplots(1, 3, figsize=(14, 4))
sns.histplot(df["price"], bins=40, ax=axes[0])
sns.histplot(np.log1p(df["price"]), bins=40, ax=axes[1])
sns.boxplot(x=df["price"], ax=axes[2])
axes[0].set_title("Price"); axes[1].set_title("log(1 + Price)")
plt.tight_layout(); plt.show()

Relationships Between Variables

A correlation matrix highlights linear relationships. Remember: correlation does not imply causation, and it misses non-linear patterns, so confirm with scatter plots.

python
corr = df.select_dtypes("number").corr()

sns.heatmap(corr, annot=True, fmt=".2f", cmap="coolwarm", center=0)
plt.title("Correlation Matrix")
plt.show()

sns.scatterplot(data=df, x="sqft", y="price", hue="neighborhood", alpha=0.6)
plt.show()

Key Takeaways

  • EDA builds understanding and exposes data quality issues early.
  • Always check shape, types, missing values and distributions.
  • Transform skewed variables when it helps interpretation.
  • Correlation is a hint, not proof of causation.

Contact Us

Have a question or feedback? Fill out the form below or reach us directly at support@nvaitraining.com