dimensionality-reduction

Guides selection and application of PCA, TruncatedSVD, LDA, t-SNE, and feature selection in scikit-learn pipelines.

Updated Dec 29, 2025
One-click install
npx skills add https://github.com/snoodleboot-io/discrecontinual_equations --skill dimensionality-reduction-snoodleboot-io
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dimensionality-reduction
Source: https://github.com/snoodleboot-io/discrecontinual_equations/tree/main/.claude/skills/dimensionality-reduction
Command: npx skills add https://github.com/snoodleboot-io/discrecontinual_equations --skill dimensionality-reduction-snoodleboot-io

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Choosing and applying dimensionality reduction incorrectly wastes accuracy, leaks validation data, and produces misleading visualizations. This Skill provides decision rules, correct scikit-learn code patterns, and anti-patterns so reduction is applied only when justified and implemented without common mistakes. ## Core Features & Use Cases - Method Selection Guidance: Decide when reduction is warranted (p ≫ n, collinearity, latency, visualization) versus when gradient boosting or feature selection is the better path. - Correct Implementations: Ready-to-use patterns for PCA with StandardScaler, TruncatedSVD for sparse TF-IDF data, LDA for supervised reduction, and t-SNE/UMAP for visualization, all fitted inside cross-validation pipelines. - Anti-Pattern Checklist: Thirteen checklist items covering leakage, sparse-matrix densification, t-SNE misinterpretation, and rank tuning against downstream metrics. - Use Case: You have a 50,000-column TF-IDF matrix and need 300 components for a classifier. The Skill directs you to TruncatedSVD instead of PCA, avoiding memory exhaustion from centring a sparse matrix. ## Quick Start Ask the AI to help reduce the dimensionality of your dataset and it will select the right method, write the scikit-learn pipeline, and check it against the anti-pattern list.

Frequently Asked Questions about dimensionality-reduction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose the number of PCA components in scikit-learn?▼

Pass a float like 0.95 to n_components to select the smallest rank reaching that explained variance ratio, or inspect the cumulative explained_variance_ratio_ curve. Better still, treat n_components as a hyperparameter and tune it with GridSearchCV against the downstream metric.

Should I use PCA or TruncatedSVD for sparse TF-IDF data?▼

Use TruncatedSVD for sparse matrices such as TF-IDF output. PCA centres the data, which densifies a sparse matrix and exhausts memory, while TruncatedSVD operates directly on the sparse input without centring.

Does PCA need feature standardization before fitting?▼

Yes, PCA is scale-dependent because variance is measured in each column's units, so a feature in dollars dominates one in years. Place a StandardScaler immediately before PCA in the same Pipeline.

Can t-SNE embeddings be used as model features in production?▼

No, t-SNE exposes no transform method, so it cannot embed unseen points and cannot appear in a serving pipeline. Use PCA or UMAP when an embedding must be applied to new data.

Why does fitting PCA before train-test splitting cause problems?▼

Fitting the reducer on the full dataset leaks validation covariance into the learned basis, inflating evaluation scores. Make the reducer a Pipeline step so it is refit within each cross-validation fold.

When should I avoid dimensionality reduction entirely?▼

Skip reduction for gradient-boosted trees on moderately correlated tabular features, since trees handle wide inputs and PCA components destroy axis-aligned splits. Also prefer feature selection when interpretability or input data-collection cost matters.