Answers.Body: <p>Your approach is totally valid (especially considering you only have a single categorical feature).</p>
  <p>If you're training a neural network though make sure to standardize your numerical features in order to be in the range [0, 1].</p>
  <p>Also, in general, and again only if you're training a neural network, you might keep in mind that there's also another valid concatenation approach, happening not at the input layer level but in a hidden layer. This is common in natural language processing, where the text features can be quite larger in number than the numerical ones. By processing separately numerical and text features we can ensure that both are mapped to a fixed size dense layer, so when the concatenation occurs, we give same importance to both types of features regardless of their respective amounts. Another advantage of this approach is that when using one hot encoding the resulting features are sparse, and by keeping them separated you can treat them accordingly (for example using a loss function for sparse features only on the one hot feature block).</p>
  <img src="https://i.sstatic.net/V0V4s.png" width="300" height="400">
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-08T19:35:45.667Z
Answers.Text: OP's post on stats.SE clarifies in a comment that the intention is to use the label to predict the label. https://stats.stackexchange.com/questions/565623/what-will-happen-if-i-concatenate-one-hot-encoded-class-along-with-features#comment1172091_565623 In other words, the proposed procedure is entirely tautological. I think this answer assumes the typical case, where a person encodes categorical *features* and uses them to predict the class *label*.
Answers.UserDisplayName: Sycorax
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-24T09:46:37.280Z
Answers.LastActivityDate: 2022-02-24T09:46:37.280Z
Answers.UserDisplayName: Edoardo Guerriero
Body: <p>Here is one row from my data:</p>
  <pre><code>H  7.042 5.781 5.399  -9.118   5.488  7.470
  </code></pre>
  <p>The first column is a categorical class. The rest of them are continuous numerical features.</p>
  <p>I encoded the classes using one-hot-encoding labels and concatenated them with the numerical features list:</p>
  <pre><code>    1   0  1  7.042 5.781 5.399  -9.118   5.488  7.470
  </code></pre>
  <p>Then I used this list for training.</p>
  <ol>
  <li>Is this a valid technique?</li>
  <li>Am I achieving anything really useful here?</li>
  </ol>
  <p>My supervisor says that I made a mistake by using labels as features. I am trying to understand what I did wrong. In my view, the mistake seems to be: when I am using labels as features, I must provide those labels as input whenever I want to use the trained model. Therefore, this trained model is practically useless. Am I correct?</p>
  <ul>
  <li>Cross posted in <a href="https://stats.stackexchange.com/questions/565623/what-will-happen-if-i-concatenate-one-hot-encoded-class-along-with-features">stats.SE</a></li>
  </ul>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-24T08:01:24.560Z
Comments.Text: when you say 'features' do you refer specifically to continuous values as opposed to one hot encoded ones?
Comments.UserDisplayName: Edoardo Guerriero
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-24T08:41:18.863Z
Comments.Text: @EdoardoGuerriero, Yes. see the edit.
Comments.UserDisplayName: user366312
Tags: <neural-networks><machine-learning><classification><training>
Title: What will happen if I concatenate one-hot-encoded categorical features along with continuous numerical features?
UserDisplayName: user366312
ThreadText: # What will happen if I concatenate one-hot-encoded categorical features along with continuous numerical features?
  
  (Asked by: username_0 on 2022-02-24)
  
  Here is one row from my data:
  
  ```
  H  7.042 5.781 5.399  -9.118   5.488  7.470
  
  ```
  
  The first column is a categorical class. The rest of them are continuous numerical features.
  
  I encoded the classes using one-hot-encoding labels and concatenated them with the numerical features list:
  
  ```
      1   0  1  7.042 5.781 5.399  -9.118   5.488  7.470
  
  ```
  
  Then I used this list for training.
  
  1. Is this a valid technique?
  2. Am I achieving anything really useful here?
  
  My supervisor says that I made a mistake by using labels as features. I am trying to understand what I did wrong. In my view, the mistake seems to be: when I am using labels as features, I must provide those labels as input whenever I want to use the trained model. Therefore, this trained model is practically useless. Am I correct?
  
  * Cross posted in [stats.SE](https://stats.stackexchange.com/questions/565623/what-will-happen-if-i-concatenate-one-hot-encoded-class-along-with-features)
  
  **Tags:** neural-networks, machine-learning, classification, training
  
  > **Comments:**
  > **username_1**: when you say 'features' do you refer specifically to continuous values as opposed to one hot encoded ones?  
  > **username_0**: @username_1, Yes. see the edit.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-02-24. Score: 1
  
  Your approach is totally valid (especially considering you only have a single categorical feature).
  
  If you're training a neural network though make sure to standardize your numerical features in order to be in the range [0, 1].
  
  Also, in general, and again only if you're training a neural network, you might keep in mind that there's also another valid concatenation approach, happening not at the input layer level but in a hidden layer. This is common in natural language processing, where the text features can be quite larger in number than the numerical ones. By processing separately numerical and text features we can ensure that both are mapped to a fixed size dense layer, so when the concatenation occurs, we give same importance to both types of features regardless of their respective amounts. Another advantage of this approach is that when using one hot encoding the resulting features are sparse, and by keeping them separated you can treat them accordingly (for example using a loss function for sparse features only on the one hot feature block).
  
  ![](https://i.sstatic.net/V0V4s.png)
  
  > **Comments:**
  > **username_2**: OP's post on stats.SE clarifies in a comment that the intention is to use the label to predict the label. https://stats.stackexchange.com/questions/565623/what-will-happen-if-i-concatenate-one-hot-encoded-class-along-with-features#comment1172091_565623 In other words, the proposed procedure is entirely tautological. I think this answer assumes the typical case, where a person encodes categorical *features* and uses them to predict the class *label*.  
  
  ---
  
  