AI-GENERATED CONTENT — PUBLISHED AS IS. This lesson derives its topic and questions from source posts on Open Education (Sayed Ahmed credited where indicated). Newly AI-generated instructional text, original example code, and synthetic plots are offered for reuse without copyright restrictions asserted by this blog. Other linked material retains its respective rights. AI can make mistakes; verify technical claims and outputs.
Advanced Data Visualization – 001 course index · Source articles: Post 76580 · Post 16176 · Post 76547 · Post 78189
Learning focus. The original 3D Scatter Plot in Python article explores wine features, univariate charts, heatmaps, parallel coordinates, box/violin plots and multidimensional graphics. A 3D scatterplot can expose structure but also hide points behind others.

Theory and design considerations
3D axes map three numeric variables, but projection and viewing angle alter apparent distances. Always report units, allow rotation where feasible, and compare two-dimensional pair plots. PCA rotates standardized variables into orthogonal components maximizing retained sample variance.
PCA is linear, sensitive to scale and extreme values, and does not necessarily preserve local neighborhoods. Methods like t-SNE/UMAP focus on other objectives and their 2D maps should not be read as true metric geography.
Mathematical model
PCA solves Σvᵢ=λᵢvᵢ for the covariance matrix Σ. Explained-variance ratio of component i is λᵢ/Σⱼλⱼ. Standardize features before PCA if units are not comparable.
Python implementation and plotted output
import numpy as np, matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA
rng=np.random.default_rng(17)
x=rng.normal(size=80)
X=np.column_stack([x,2*x+rng.normal(size=80)*.5,
-x+rng.normal(size=80)*.7])
fig=plt.figure(figsize=(7,4))
ax=fig.add_subplot(111,projection="3d")
ax.scatter(X[:,0],X[:,1],X[:,2],alpha=.55)
ax.set(xlabel="X",ylabel="Y",zlabel="Z")
plt.show()
pca=PCA(n_components=2).fit(StandardScaler().fit_transform(X))
print("Explained ratio:",pca.explained_variance_ratio_)
R implementation and plotted output
# install.packages("scatterplot3d") if needed
library(scatterplot3d)
set.seed(17); x <- rnorm(80)
d <- data.frame(X=x,Y=2*x+rnorm(80)*.5,
Z=-x+rnorm(80)*.7)
scatterplot3d(d$X,d$Y,d$Z,pch=19,cex.symbols=.55,
main="Synthetic 3D observations")
pc <- prcomp(d,center=TRUE,scale.=TRUE)
print(summary(pc)$importance[2,1:2])
plot(pc$x[,1:2],xlab="PC1",ylab="PC2",
main="Two-dimensional PCA projection")
Expected output
The three variables were generated from a shared latent x, so the first principal component should explain most standardized variance. The exact ratio differs by pseudorandom generator and seed between R and Python.
Questions with answers
Q1. Does a 3D scatterplot add a third independent dimension of information?
Answer. It encodes another measured variable, but may increase occlusion and perspective bias.
Q2. Why standardize before PCA?
Answer. To avoid variables with large numerical units dominating covariance without substantive justification.
Q3. Can PCA components be interpreted causally?
Answer. No. They are linear combinations chosen for variance, not necessarily underlying causes.
Assessment and practical assignment
Compare a 3D scatter, pairplot and PCA map of the same synthetic dataset; report where occlusion creates misinterpretation.
Translated to Bengali / বাংলায় অনুবাদ
বাংলা অনুবাদ: ওপরের পাঠের ব্যাখ্যা, গাণিতিক ধারণা, ফল ও প্রশ্নোত্তরের সহজ কিন্তু যথাযথ বাংলা অনুবাদ নিচে দেওয়া হয়েছে। কোডের ভাষা Python, R ও JavaScript অপরিবর্তিত রাখা হয়েছে।
পাঠের উদ্দেশ্য: সাইটের 3D Scatter Plot লেখায় ওয়াইনের বিভিন্ন চলক, হিটম্যাপ, প্যারালাল কো-অর্ডিনেট ও ভায়োলিন চার্ট দেখানো হয়েছে। ৩-মাত্রিক স্ক্যাটারপ্লটে সম্পর্ক দেখা গেলেও অন্য বিন্দুর আড়ালে কিছু বিন্দু লুকাতে পারে।
৩-মাত্রিক অক্ষে তিনটি চলক দেখানো হয়; দৃশ্যকোণ বদলালে দূরত্বের ধারণা বদলাতে পারে। একক ও বিকল্প ২-মাত্রিক চার্ট দিন। PCA-তে চলকগুলোকে নতুন পরস্পর লম্ব অক্ষে প্রকাশ করা হয় যাতে যতটা সম্ভব ভ্যারিয়েন্স সংরক্ষিত থাকে।
PCA রৈখিক এবং স্কেল ও চরম মানের প্রতি সংবেদনশীল। t-SNE বা UMAP অন্য লক্ষ্য অনুসরণ করে; তাদের ২-মাত্রিক বিন্যাসকে বাস্তব দূরত্বের মানচিত্র ভাবা উচিত নয়।
গণিত: PCA-তে covariance ম্যাট্রিক্স Σ-এর জন্য Σvᵢ=λᵢvᵢ সমাধান করা হয়। i নম্বর উপাদানের ব্যাখ্যাত ভ্যারিয়েন্স অনুপাত λᵢ/Σⱼλⱼ। ভিন্ন এককের চলক আগে মানসম্মত করুন।
প্রত্যাশিত ফল: তিনটি চলক একই লুকায়িত x থেকে তৈরি হওয়ায় প্রথম প্রধান উপাদান অধিকাংশ ভ্যারিয়েন্স ব্যাখ্যা করবে। Python ও R-এর র্যান্ডম নমুনা আলাদা হওয়ায় সুনির্দিষ্ট শতাংশ আলাদা হতে পারে।
প্রশ্ন 1. ৩-মাত্রিক চার্ট কি সবসময় বেশি তথ্য দেয়?
উত্তর: আরেকটি চলক দেখালেও আড়াল ও দৃশ্যকোণের বিভ্রান্তি বাড়তে পারে।
প্রশ্ন 2. PCA-এর আগে মানসম্মত কেন করব?
উত্তর: বড় এককের চলক যেন যুক্তিহীনভাবে বেশি গুরুত্ব না পায়।
প্রশ্ন 3. PCA-এর উপাদান কি কারণ বোঝায়?
উত্তর: না। এগুলো ভ্যারিয়েন্সের ভিত্তিতে গঠিত রৈখিক সমন্বয়।
বাংলা অনুশীলন
একই কৃত্রিম উপাত্তের ৩-মাত্রিক স্ক্যাটার, জোড়াভিত্তিক চার্ট ও PCA তুলনা করে আড়াল হওয়ার সমস্যা লিখুন।
মূল উৎসের লিংক পোস্টের শুরুতে দেওয়া আছে। এআই-তৈরি নতুন লেখা ও মৌলিক নমুনা-চিত্র পুনর্ব্যবহারে এই ব্লগ থেকে কপিরাইটের দাবি করা হচ্ছে না; তৃতীয় পক্ষের অধিকার পৃথক। এআই ভুল করতে পারে—যাচাই করুন।
Discover more from Open Education
Subscribe to get the latest posts sent to your email.
