seniorPCA

How does PCA behave when applied before vs after train-test split?

Updated May 17, 2026

Short answer

Applying PCA before splitting can cause data leakage and inflate model performance.

Deep explanation

PCA learns variance structure from entire dataset. If applied before train-test split, test data influences principal components, leading to information leakage. Proper approach is fitting PCA only on training data and transforming test data using the same model.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More PCA interview questions

View all →