How to using Linear Discriminant Analysis for classify training and testing dataset?

조회 수: 7 (최근 30일)
I have a little confused about using Linear Discriminant Analysis (LDA) algorithm for classification after reading some articles.
1. Based on my understanding, for classification, training data and testing data should be separated. When reducing the dimension by LDA, I should combine training data and testing data together to reduce dimension, or just reduce training data dimension, and use eigenvector W to map testing data to lower dimension?
2. For standardized dataset mentioned in some article, I should standardize the whole data (training and testing) together, or just standardized the training data, and use the same scale mapping the testing data?

답변 (1개)

Prantik Chatterjee
Prantik Chatterjee 2024년 3월 21일
1. Your second approach is the correct one. While reducing dimensionality using LDA, you should first fit the LDA model only on the training data and then use the transformation (eigenvector (W)) learned from the training data to map both the training and testing data to a lower dimension.
2. The same answer applies for data standardization as well. You should first standardize the training data and then use the standardization scale from the training data to scale the test data.
The reason for both of the above cases, is to avoid issues such as data leakage. Combining training and test data before any kind of transformation may lead to data leakage, where information from the testing data influences the model training process. This can result in overly optimistic performance metrics and a model that doesn't generalize well to unseen data.

카테고리

Help CenterFile Exchange에서 Discriminant Analysis에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by