I am working with a dataset, X, and have applied PCA to reduce its dimensionality down to three principal components (PC1, PC2, and PC3). Following that, I used LDA to maximize the separation between two classes, resulting in LD1.
My challenge is to plot the loadings of LD1 features. Normally, if loadings are obtained solely from PCA, the number of columns in the dataset is used as the x-axis. However, since I am working with spectral analyses, I need to visualize the LD1 feature loadings.
Here is the code I have written so far:
# Performing PCA
n_components=3
pca = PCA(n_components)
X_pca = pca.fit_transform(X)
# Performing LDA
lda = LinearDiscriminantAnalysis(n_components=1)
X_lda = lda.fit_transform(X_pca, y)
# Combine PCA components and LDA loadings
combined_loadings = np.dot(lda.coef_, pca.components_)
Any help would be greatly appreciated.