Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Day-4 – Data Visualization (Matplotlib + Data Insights)

🧠 Why Visualization Matters

In AI:

  • Raw data → hard to understand
  • Graphs → instant insights

Example:

  • Table → boring
  • Chart → story

🚀 Part 1 – Setup Matplotlib

In Colab:

import matplotlib.pyplot as plt


🚀 Part 2 – Line Chart

Example:

marks = [70, 80, 90, 85, 95]

plt.plot(marks)
plt.title("Marks Trend")
plt.xlabel("Student Index")
plt.ylabel("Marks")

plt.show()

👉 This shows trend over time/index.

🚀 Part 3 – Bar Chart

Best for comparisons.

names = ["A", "B", "C", "D"]
marks = [70, 85, 90, 60]

plt.bar(names, marks)
plt.title("Student Marks Comparison")

plt.show()


🚀 Part 4 – Histogram (VERY IMPORTANT FOR AI)

Used to understand data distribution.

marks = [70, 80, 85, 90, 95, 60, 75, 88]

plt.hist(marks)
plt.title("Marks Distribution")

plt.show()

👉 Helps detect:

  • Normal distribution
  • Outliers
  • Skewness


🚀 Part 5 – Scatter Plot

Used to find relationships.

age = [20, 21, 22, 23]
marks = [70, 75, 85, 90]

plt.scatter(age, marks)
plt.title("Age vs Marks")

plt.xlabel("Age")
plt.ylabel("Marks")

plt.show()

👉 Helps identify:

  • Correlation
  • Trends


🧠 AI Insight (Very Important)

Scatter plots often show relationships that can be approximated by linear models:

This is the foundation of:

  • Linear Regression (Day-5)
  • ML predictions


🚀 Part 6 – Use Your CSV Data

Now use your real dataset:

import pandas as pd
import matplotlib.pyplot as plt

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

# Bar chart
plt.bar(df["Name"], df["Marks"])
plt.title("Marks by Student")

plt.show()

Histogram:

plt.hist(df["Marks"])
plt.title("Marks Distribution")

plt.show()


🎯 Mini Practice (Do This)

Using your CSV:

1️⃣ Plot Marks vs Age (scatter)
2️⃣ Plot Marks distribution (histogram)
3️⃣ Plot bar chart of names vs marks


🎯 End of Day-4 Goals

You should now:

✅ Create charts
✅ Understand data visually
✅ Identify patterns
✅ Prepare content for blog/video


Github Link: https://github.com/dotnetfullstackdeveloper/ai-engineer-journey/blob/main/Week-01-AI-Foundations/Day-4%3A%20Data%20Visualization

Post a Comment

0 Comments