Data Visualization পরিচিতি
গল্প: সেলস রিপোর্টের কাহিনী 📊
একটি বড় সুপারশপের মালিক রাফিউল সাহেব। তার ম্যানেজার প্রতি মাসে ৫০০ লাইনের Excel ফাইল পাঠায়। রাফিউল সাহেব ঘণ্টার পর ঘণ্টা দেখেও বুঝতে পারছেন না — কোন পণ্য ভালো বিকোচ্ছে, কোন মাসে বিক্রি বেশি। তারপর একজন Data Analyst এসে একটি রঙিন চার্ট দেখাল — মাত্র ৩০ সেকেন্ডে রাফিউল সাহেব বুঝলেন সব! এটাই Data Visualization-এর শক্তি।
📖 Data Visualization কী?
Data Visualization হলো সংখ্যা ও তথ্যকে চার্ট, গ্রাফ ও ছবির মাধ্যমে দৃশ্যমান করা — যাতে মানুষ দ্রুত বুঝতে পারে এবং সিদ্ধান্ত নিতে পারে।
🖱️ Interactive: টেবিল থেকে চার্ট — একই ডেটা, দুই রূপ
নিচের ৫ মাসের বিক্রি ডেটা দেখুন। টেবিল ও চার্টের মধ্যে পাল্টান।
| মাস | বিক্রি (টাকা) |
|---|
🧠 মানুষের মস্তিষ্ক ছবি বোঝে দ্রুত!
গবেষণায় দেখা গেছে, মানুষের মস্তিষ্ক একটি ছবি প্রক্রিয়া করতে মাত্র ১৩ মিলিসেকেন্ড নেয়। কিন্তু ৫০০ লাইনের টেবিল বুঝতে লাগে মিনিটের পর মিনিট।
Chart Gallery — এক ডেটা, সব চার্ট
🛒 shopSales Dataset
একই shopSales ডেটাসেট থেকে ১২+ ভিন্ন chart দেখব। প্রতিটি card-এ ডেটা | চার্ট | কোড tab আছে — ক্লিক করে explore করুন।
🎚️ Live Bar Chart Builder
স্লাইডার দিয়ে মাসিক বিক্রি বদলান — চার্ট তাৎক্ষণিক আপডেট হবে। সর্বোচ্চ বার হাইলাইট হবে।
🎯 Chart Picker Game
প্রশ্ন পড়ে সঠিক chart type বেছে নিন।
EDA — ডেটা বোঝার প্রথম ধাপ
গল্প: ডাক্তারের পরীক্ষা 🏥
একজন ভালো ডাক্তার সরাসরি ওষুধ লেখেন না। প্রথমে রোগীর সম্পূর্ণ পরীক্ষা করেন। EDA একই কাজ করে ডেটার জন্য — সরাসরি ML মডেল চালালে ভুল ফলাফল আসে!
📖 EDA কী?
Exploratory Data Analysis (EDA) হলো ডেটাকে পদ্ধতিগতভাবে বিশ্লেষণ করা — Missing Value, Outlier, Distribution, Correlation দেখা। Data Science-এর সবচেয়ে গুরুত্বপূর্ণ প্রথম ধাপ।
🔬 EDA Step-by-Step Lab
প্রতিটি ধাপে ক্লিক করুন — কী করবেন ও কী শিখবেন দেখুন।
✅ EDA Checklist (ক্লিক করে টিক দিন)
সঠিক Chart বেছে নেওয়া
🧭 Chart Decision Wizard
দুইটি প্রশ্নের উত্তর দিন — সঠিক chart সুপারিশ পাবেন।
ধাপ ১: আপনার ডেটা কী ধরনের?
ধাপ ২: আপনি কী দেখাতে চান?
🎯 Chart নির্বাচনের সারাংশ
| লক্ষ্য | সেরা Chart |
|---|---|
| Category তুলনা | 📊 Bar Chart |
| সময়ের সাথে পরিবর্তন | 📈 Line Chart |
| অংশ/ভাগ (%) | 🥧 Pie Chart |
| বণ্টন | 📉 Histogram / Box Plot |
| দুটো সংখ্যার সম্পর্ক | ⚫ Scatter Plot |
| Correlation | 🌡️ Heatmap |
Google Colab হাতে-কলমে
📋 Project: সুপারশপের বিক্রি বিশ্লেষণ (shopSales)
Part 02-এর Chart Gallery-তে যে shopSales ডেটা দেখেছেন — সেটাই এখানে Python-এ। ধাপ ১: setup চালান → ধাপ ২: Basic EDA (shape, missing, describe…) → ধাপ ৩: chart visualize। Chip থেকে যেকোনো EDA step বা chart-এ jump করুন — সব একই df ব্যবহার করে।
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import warnings warnings.filterwarnings('ignore') plt.style.use('seaborn-v0_8') sns.set_palette('husl') # মাসের ক্রম — Line, Area, Stacked chart-এ ব্যবহার হবে month_order = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] # Rafiul সাহেবের সুপারশপ — gallery-র একই shopSales ডেটা np.random.seed(42) n = 500 df = pd.DataFrame({ 'Month': np.random.choice(month_order, n), 'Category': np.random.choice(['Electronics','Food','Clothing','Books','Toys'], n), 'Sales': np.random.randint(500, 10000, n), 'Customers': np.random.randint(10, 200, n), 'Satisfaction': np.random.uniform(3.0, 5.0, n).round(1), 'Latitude': np.random.uniform(23.70, 23.90, n).round(4), 'Longitude': np.random.uniform(90.35, 90.45, n).round(4) }) print('Dataset তৈরি!', df.shape) print(df.head())
df দিয়ে নিচের EDA ও সব chart চালাবেন — আলাদা ডেটা লাগবে না।EDA ও Chart — কোডে যেতে ক্লিক করুন
Teal chip = Basic EDA · Blue chip = Chart visualization — setup-এর পর যেকোনো ক্রমে চালান।
এই step দিয়ে কী বুঝবেন: Dataset কত বড় (সারি/কলাম) এবং ডেটা দেখতে কেমন।
print('Shape:', df.shape) # (500, 7) — 500 rows, 7 columns print('\nFirst 5 rows:') display(df.head()) # Colab-এ display(); না থাকলে print(df.head()) print('\nLast 3 rows:') display(df.tail(3))
এই step দিয়ে কী বুঝবেন: কোন column সংখ্যা (int/float) আর কোনটা text (object)।
print('Column types:') print(df.dtypes) print('\n--- df.info() ---') df.info()
এই step দিয়ে কী বুঝবেন: কোন column-এ ফাঁকা (null) value আছে কিনা।
missing = df.isnull().sum() print('Missing per column:') print(missing) print('\nTotal missing:', missing.sum()) # real dataset-এ missing থাকলে: drop / fill / impute করতে হবে # df = df.dropna() # সারি মুছে ফেলা # df['Sales'].fillna(0) # 0 দিয়ে পূরণ
এই step দিয়ে কী বুঝবেন: সংখ্যার mean/min/max/std এবং category frequency।
print('Numeric summary:') display(df.describe()) print('\nCategory count:') print(df['Category'].value_counts()) # outlier দেখতে Box Plot chip (#colab-box) এ যান
এই step দিয়ে কী বুঝবেন: Sales কোন range-এ বেশি — distribution কেমন।
print('Sales stats:', df['Sales'].describe()) plt.figure(figsize=(10, 5)) plt.hist(df['Sales'], bins=20, color='#0F6E56', edgecolor='white', alpha=0.85) sns.kdeplot(df['Sales'], color='#085041', linewidth=2) plt.title('Sales Distribution (Histogram + KDE)') plt.xlabel('Sales (টাকা)'); plt.ylabel('Frequency') plt.tight_layout(); plt.show() # styled chart → Histogram chip (#colab-histogram)
এই step দিয়ে কী বুঝবেন: Sales, Customers, Satisfaction-এর মধ্যে সম্পর্ক (+1 = একসাথে বাড়ে)।
num_cols = ['Sales', 'Customers', 'Satisfaction'] corr = df[num_cols].corr() print('Correlation matrix:') display(corr) print(f"\nSales ↔ Customers: {corr.loc['Sales','Customers']:.2f}") # ~0.7+ মানে positive relationship — বেশি customer, বেশি sales # visual heatmap → Heatmap chip (#colab-heatmap)
এই chart দিয়ে কী বুঝবেন: Category অনুযায়ে মোট বিক্রি তুলনা — কোন পণ্য সবচেয়ে বেশি বিক্রি?
cat_sales = df.groupby('Category')['Sales'].sum().sort_values(ascending=False) plt.figure(figsize=(10, 5)) plt.bar(cat_sales.index, cat_sales.values, color='#185FA5', edgecolor='white') plt.title('Category অনুযায়ী মোট বিক্রি') plt.xlabel('Category'); plt.ylabel('মোট বিক্রি (টাকা)') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: মাসিক বিক্রির trend — কোন মাসে বিক্রি বেশি/কম?
monthly = df.groupby('Month')['Sales'].sum().reindex(month_order) plt.figure(figsize=(10, 5)) plt.plot(monthly.index, monthly.values, marker='o', color='#3B6D11', linewidth=2) plt.title('মাসিক বিক্রির Trend') plt.xlabel('Month'); plt.ylabel('বিক্রি') plt.xticks(rotation=45); plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: মোট বিক্রির মধ্যে প্রতিটি category-র অংশ (%).
cat_sales = df.groupby('Category')['Sales'].sum() plt.figure(figsize=(8, 8)) plt.pie(cat_sales.values, labels=cat_sales.index, autopct='%1.1f%%', startangle=90) plt.title('Category অনুযায়ী Market Share') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: Sales-এর distribution — কোন range-এ বেশি transaction?
plt.figure(figsize=(10, 5)) plt.hist(df['Sales'], bins=20, color='#185FA5', edgecolor='white') plt.title('Sales-এর Distribution') plt.xlabel('Sales (টাকা)'); plt.ylabel('Frequency') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: Sales vs Customers — বেশি customer = বেশি sales?
plt.figure(figsize=(10, 5)) plt.scatter(df['Customers'], df['Sales'], alpha=0.6, color='#185FA5') plt.title('Customers বনাম Sales') plt.xlabel('Customers'); plt.ylabel('Sales') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: Category অনুযায়ে Sales-এর median ও outlier।
plt.figure(figsize=(10, 5)) sns.boxplot(data=df, x='Category', y='Sales', palette='husl') plt.title('Category অনুযায়ী Sales (Box Plot)') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: প্রতিটি category কতবার এসেছে — frequency।
plt.figure(figsize=(10, 5)) sns.countplot(data=df, x='Category', palette='husl') plt.title('Category Frequency (Count Plot)') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: Feature-গুলোর মধ্যে correlation — কোনটা কোনটার সাথে সম্পর্কিত?
num_cols = ['Sales', 'Customers', 'Satisfaction'] plt.figure(figsize=(8, 6)) sns.heatmap(df[num_cols].corr(), annot=True, cmap='coolwarm', fmt='.2f') plt.title('Correlation Matrix') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: Cumulative মাসিক বিক্রি — মোট কত জমা হচ্ছে?
monthly = df.groupby('Month')['Sales'].sum().reindex(month_order) cumulative = monthly.cumsum() plt.figure(figsize=(10, 5)) plt.fill_between(range(len(cumulative)), cumulative.values, alpha=0.4, color='#3B6D11') plt.plot(range(len(cumulative)), cumulative.values, color='#3B6D11', linewidth=2) plt.xticks(range(12), month_order, rotation=45) plt.title('Cumulative মাসিক বিক্রি') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: মাসে মাসে প্রতিটি category-র অবদান।
pivot = df.pivot_table(index='Month', columns='Category', values='Sales', aggfunc='sum').reindex(month_order) pivot.plot(kind='bar', stacked=True, figsize=(12, 6), colormap='husl') plt.title('মাসিক Stacked Bar — Category ভাগ') plt.xlabel('Month'); plt.legend(title='Category', bbox_to_anchor=(1.05, 1)) plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: Category অনুযায়ী Satisfaction-এর shape।
plt.figure(figsize=(10, 5)) sns.violinplot(data=df, x='Category', y='Satisfaction', palette='husl') plt.title('Category অনুযায়ী Satisfaction') plt.tight_layout(); plt.show()
এই chart দিয়ে কী বুঝবেন: ডেলিভারি লোকেশন — ঢাকায় কোথায় বেশি order?
plt.figure(figsize=(10, 8)) plt.scatter(df['Longitude'], df['Latitude'], s=df['Sales']/50, alpha=0.6, c=df['Sales'], cmap='viridis') plt.colorbar(label='Sales') plt.title('Delivery Locations (ঢাকা)') plt.xlabel('Longitude'); plt.ylabel('Latitude') plt.tight_layout(); plt.show()
Revision & MCQ
⚡ Quick Revision
Bar = Category তুলনা · Line = Trend · Pie = % ভাগ · Histogram = Distribution · Box = Outlier · Scatter = Relationship · EDA = Model-এর আগে!
📝 MCQ — বিকল্পে ক্লিক করুন
📌 পরবর্তী ক্লাসে (Advanced Topics)
Time Series: Trend, Seasonality, Cyclic pattern — Line/Area chart দিয়ে দীর্ঘমেয়াদী বিশ্লেষণ।
Geospatial: Latitude/Longitude দিয়ে মানচিত্রে ডেটা — Food delivery, ride sharing।
Full Dashboard: ৬+ chart একসাথে subplots(2,3) দিয়ে — business presentation-এর জন্য।
→ পরবর্তী: Module 10 Advanced Data Visualization — Text ৫ · Multidim ৫ · Comparative ৪
🎉 অভিনন্দন! Module 01 সম্পন্ন!
আপনি শিখেছেন: Visualization-এর শক্তি, ১২+ Chart Type, EDA workflow, Chart selection ও Python কোডিং ভিত্তি।
পরের module: Data Processing for ML →