liveBook · Manning

Dimensionality reduction

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

Dimensionality reduction transforms data with many variables into a lower-dimensional representation while attempting to preserve important structure or information.

Dimensionality reduction converts many numeric variables into a few summary dimensions, making complex tabular data easier to visualize and inspect for patterns or anomalies. section 2.4.3

Choose an approach according to the structure you need to preserve:

  • PCA and SVD create dimensions through weighted linear combinations of features, making them useful for broadly linear structure. section 2.4.3
  • t-SNE and UMAP can reveal nonlinear patterns, clusters, and isolated points, but their projections depend strongly on hyperparameters. section 2.4.3
  • Treat a projection as an exploratory aid rather than a definitive representation: information loss can produce misleading or difficult-to-interpret plots. section 2.4.3

A practical t-SNE inspection

Select numeric and ordinal features, fill missing values with column means, fit a two-dimensional t-SNE projection, and plot the resulting points to inspect clusters and anomalies. section 2.4.3

Listing 2.9 Plotting a t-SNE low-dimensional projection of a dataset
from sklearn.manifold import TSNE                           #1
import matplotlib.pyplot as plt                             #2
 
tsne = TSNE(n_components=2, 
            perplexity=30., 
            init="random", 
            learning_rate="auto",
            random_state=42)                                #3
 
X = data[numeric_feats + ordinal_feats].fillna(
            data[numeric_feats + ordinal_feats].mean())     #4
projection_2D = tsne.fit_transform(X)                       #5
 
plt.figure(figsize=(15, 15))
plt.scatter(projection_2D[:, 0], projection_2D[:, 1],
            edgecolor='none', 
            alpha=0.80, 
            s=10) 
plt.show()                                                  #6

Runnable scikit-learn code demonstrates two-dimensional t-SNE projection and visualization. section 2.4.3

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Explains projection choices, preprocessing, plotting, and interpretation caveats, but stops short of mathematical derivations.
Examples
Demonstrates a two-dimensional t-SNE scatter plot built from numeric and ordinal tabular features.
What it assumes
Assumes tabular features and basic numeric preprocessing, while requiring all features used by multivariate methods to be numeric.
What you can do after
Diagnose patterns and anomalies by generating and interpreting low-dimensional exploratory plots.
How it connects
Connects dimensionality reduction with exploratory data analysis, PCA, SVD, t-SNE, UMAP, clustering, and anomaly detection.

Also explained in

Compare how 11 books explain dimensionality reduction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.