What do you mean by Linear Discriminant Analysis?
Linear Discriminant Analysis is a supervised algorithm as it takes the class label into consideration. It is a way to reduce ‘dimensionality’ while at the same time preserving as much of the class discrimination information as possible.
LDA helps to find the boundaries around clusters of classes. It projects data points on a line so that your clusters are as separated as possible, with each cluster having a relative distance to a centroid. LDA finds a centroid of each class datapoints.
PCA performs better in case where number of samples per class is less. Whereas LDA works better with large dataset having multiple classes; class separability is an important factor while reducing dimensionality.
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA lda = LDA(n_components=1) X_train = lda.fit_transform(X_train, y_train) X_test = lda.transform(X_test)
Leave a comment
You must be logged in to post a comment.