# How to convert my test data in the same dimensionality as my train data

I have trained a VAE with jpg images. My latent space dimension has 768 features and when plotting the latent space it looks like this:

However, when I use the scikit learn tool LDA (Linear Discriminant Analysis) to reduce to two dimensions it looks like this:

This is the code:

features,sigma, mean = encoder.predict(x_train)
#Features have 768 dimensions
lda =LinearDiscriminantAnalysis(
n_components=2)
labels = y_train
digit_features_lda=lda.fit_transform(features,labels)
#digit_features_lda are two dimensional


I dont have the labels for the test data, I can encode to 768 dimensions but LDA requires labels to reduce to two dimensions.

• How did you reduce/project the dimeansion of 768 to create the first plot (which is 2D)? Mar 23, 2023 at 15:29
• Hi @Dude Rar, and welcome to AI Stack Exchange! If possible, please edit this question to include a specific question in the body of your post. Mar 23, 2023 at 15:53
• @Broele I only took two dimensions. i.e. encoder[0] and encoder[1]. Mar 24, 2023 at 0:56

LinearDiscriminantAnalysis is an scikit-learn transformer. These typically have to steps:
1. fit(X,y): This step is used to train the transformation. Depending on the transformer, the target variable / the labels might be used, here. As input, one uses the training data with labels. In case of LinearDiscriminantAnalysis, you could understand the fit method as finding a transformation of the features X, that allows to separate the classes (given by y) best. To find the transformation, the algorithm needs to know y.
2. transform(X): This step applys the trained transformation to input samples. This can be training data, testing data or some other data (with the correct dimension). Since the transformation is already trained, it does not need to know the labels anymore.
digit_features_lda_test = lda.transform(test_features)