Visualizing High-Dimensional Data
Real datasets often have dozens or hundreds of columns, but a screen has only two dimensions. This topic introduces ways to show many variables at once and to reduce them to something you can see.
a. Challenges of Many Variables
With more than three variables, simple charts stop working. You can add color, size, and shape, but the chart quickly becomes hard to read. This problem is often called the curse of dimensionality.
Many variables are also correlated, so they carry repeated information. A smart approach is to find the main patterns and show those, rather than plotting everything.
There are two main strategies. One is to design charts that handle many variables at once. The other is to reduce the data to two or three new dimensions that keep most of the structure.
b. Parallel Coordinates Plots
A parallel coordinates plot places each variable as a vertical axis. Each row of data becomes a line that crosses all the axes. Lines that follow similar paths belong to similar items.
import plotly.express as px
fig = px.parallel_coordinates(df, color="species",
dimensions=["sepal_length", "sepal_width",
"petal_length", "petal_width"])
fig.show()You can drag along an axis to select a range and highlight matching lines. This helps find groups and unusual rows.
Scale the variables to a similar range first, or the axes with the biggest numbers will dominate. Limit the number of axes, since too many make the plot busy.
c. Dimensionality Reduction with PCA
Principal Component Analysis, or PCA, creates new axes, called components, that capture as much variation as possible. Plotting the first two components often shows a good overview of the data.
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
X_scaled = StandardScaler().fit_transform(X)
pca = PCA(n_components=2)
components = pca.fit_transform(X_scaled)
plt.scatter(components[:, 0], components[:, 1], c=y)
print(pca.explained_variance_ratio_)The explained variance ratio tells you how much of the information each component keeps. If the first two keep most of it, the plot is a faithful summary.
Always scale the data before PCA. The axes are mixtures of the original variables, so they can be hard to explain in plain words.
d. Visualizing Clusters with t-SNE and UMAP
t-SNE and UMAP are methods that reduce data to two dimensions while keeping similar items close together. They are excellent for revealing clusters in complex data, such as images or text.
from sklearn.manifold import TSNE
tsne = TSNE(n_components=2, perplexity=30, random_state=42)
embedding = tsne.fit_transform(X_scaled)
plt.scatter(embedding[:, 0], embedding[:, 1], c=y)UMAP is available in the umap-learn package and is usually faster and better at keeping the large-scale structure. Both are for visualization and exploration, not for exact measurement.
Be careful when reading these plots. The distances between clusters and the size of clusters may not be meaningful, and results change with the settings. Try several settings before drawing conclusions.
Data Visualization Tutorial
Wesline Rinisha








