Answers.Body: <p><code>LinearDiscriminantAnalysis</code> is an scikit-learn transformer. These typically have to steps:</p>
  <ol>
  <li><code>fit(X,y)</code>: 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 <code>LinearDiscriminantAnalysis</code>, you could understand the <code>fit</code> method as finding a transformation of the features <code>X</code>, that allows to separate the classes (given by <code>y</code>) best. To find the transformation, the algorithm needs to know <code>y</code>.</li>
  <li><code>transform(X)</code>: 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.</li>
  </ol>
  <p>Having that said, just call</p>
  <pre><code>digit_features_lda_test = lda.transform(test_features)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-30T14:47:21.557Z
Answers.Text: how can I save this lda transform in a variable? lets say I want to share to test my model
Answers.UserDisplayName: Dude Rar
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-31T14:34:05.293Z
Answers.Text: This should be a question on its own
Answers.UserDisplayName: Broele
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-23T15:43:44.360Z
Answers.LastActivityDate: 2023-03-23T15:43:44.360Z
Answers.UserDisplayName: Broele
Body: <p>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:
  <a href="https://i.sstatic.net/4yGUR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4yGUR.png" alt="latent space only on two dimensions" /></a></p>
  <p>However, when I use the scikit learn tool LDA (Linear Discriminant Analysis) to reduce to two dimensions it looks like this:</p>
  <p><a href="https://i.sstatic.net/6n74y.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6n74y.png" alt="LDA reduction" /></a></p>
  <p>This is the code:</p>
  <pre><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
  </code></pre>
  <p>I dont have the labels for the test data, I can encode to 768 dimensions but LDA requires labels to reduce to two dimensions.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-23T15:29:12.753Z
Comments.Text: How did you reduce/project the dimeansion of 768 to create the first plot (which is 2D)?
Comments.UserDisplayName: Broele
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-23T15:53:40.207Z
Comments.Text: 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.
Comments.UserDisplayName: DeepQZero
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-24T00:56:45.103Z
Comments.Text: @Broele I only took two dimensions. i.e. encoder[0] and encoder[1].
Comments.UserDisplayName: Dude Rar
Tags: <neural-networks><deep-learning><tensorflow><variational-autoencoder><scikit-learn>
Title: How to convert my test data in the same dimensionality as my train data
UserDisplayName: Dude Rar
ThreadText: # How to convert my test data in the same dimensionality as my train data
  
  (Asked by: username_0 on 2023-03-23)
  
  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.
  
  **Tags:** neural-networks, deep-learning, tensorflow, variational-autoencoder, scikit-learn
  > **Comments:**
  > **username_1**: How did you reduce/project the dimeansion of 768 to create the first plot (which is 2D)?  
  > **username_2**: 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.  
  > **username_0**: @Broele I only took two dimensions. i.e. encoder[0] and encoder[1].  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-03-23. Score: 0 | Accepted answer
  
  LinearDiscriminantAnalysis is an scikit-learn transformer. These typically have to steps:
  
  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.
  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.
  
  Having that said, just call
  digit_features_lda_test = lda.transform(test_features)
  
  > **Comments:**
  > **username_0**: how can I save this lda transform in a variable? lets say I want to share to test my model  
  > **username_1**: This should be a question on its own  
  
  ---
  
  