Answers.Body: <p>Many machine learning models used for regression <em>will</em> interpolate their predictions as you seem to want, and can return target values not seen in the training set.</p>
  <p>For example, basic linear regression will do this provided at least one of the input variables is also continuous. Also neural networks.</p>
  <p>There are some cases where it may not happen:</p>
  <ul>
  <li><p>Decision tree-based algorithms (such as random forests) approximate with combinations of step functions, so most will output a set of discrete values. However, in practice this set will include many values that are not in the training set, and it is usually not a real concern, if your goal is accurate predictions for unseen data.</p>
  </li>
  <li><p>If all the input features are discrete, then there will be a discrete set of output values, equal in number to all the possible combinations of input. Again, this may not be a practical concern in your case, and will very likely generate outputs that are not in the training set.</p>
  </li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-03T19:41:05.970Z
Answers.LastActivityDate: 2022-02-03T19:41:05.970Z
Answers.UserDisplayName: Neil Slater
Answers.Body: <p>As long as you train the model with a proper <a href="https://machinelearningmastery.com/how-to-choose-loss-functions-when-training-deep-learning-neural-networks/" rel="nofollow noreferrer">loss function</a> for regression the model will learn to output any continuous values, not restricted to and most likely not exactly equal to the labels your providing during training, rather an approximation of them based on the level of generalization the model manage to learn.</p>
  <p>The range of values the model can learn to output will also depend on the final activation function of your model. Using a sigmoid is indeed a good choice if your labels belong in the range 0-1.</p>
  <p>If instead you don't want the model to learn continuous values then you need to frame the task as a classification problem, and convert your set of finite real values labels into a discrete representation, for example using <a href="https://machinelearningmastery.com/why-one-hot-encode-data-in-machine-learning/" rel="nofollow noreferrer">one hot encoding</a> and then train the model with a loss suited for classification.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-03T19:39:06.797Z
Answers.LastActivityDate: 2022-02-03T19:39:06.797Z
Answers.UserDisplayName: Edoardo Guerriero
Body: <p>I have a textual dataset that has a set of real numbers as labels: L={0.0, 0.33, 0.5, 0.75, 1.0}, and I have a model that takes the text as input and has a Sigmoid output.</p>
  <p>If I train the model on this data, will the model keep generating labels that exactly equal one of the values in L? or it might generate, as an example, 0.4?</p>
  <p>If not, is there a solution for that?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-03T19:32:33.023Z
Comments.Text: To clarify: You want the model to be able to generate a 0.4 if that would be the best estimate given the input data?
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-02-03T19:40:58.747Z
Comments.Text: yes @NeilSlater
Comments.UserDisplayName: Minions
Tags: <neural-networks><classification><linear-regression><sigmoid>
Title: Training a regression model on a set of values in 0-1 range to give 0-1 continual values
UserDisplayName: Minions
ThreadText: # Training a regression model on a set of values in 0-1 range to give 0-1 continual values
  
  (Asked by: username_0 on 2022-02-03)
  
  I have a textual dataset that has a set of real numbers as labels: L={0.0, 0.33, 0.5, 0.75, 1.0}, and I have a model that takes the text as input and has a Sigmoid output.
  
  If I train the model on this data, will the model keep generating labels that exactly equal one of the values in L? or it might generate, as an example, 0.4?
  
  If not, is there a solution for that?
  
  **Tags:** neural-networks, classification, linear-regression, sigmoid
  > **Comments:**
  > **username_1**: To clarify: You want the model to be able to generate a 0.4 if that would be the best estimate given the input data?  
  > **username_0**: yes @NeilSlater  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2022-02-03. Score: 2 | Accepted answer
  
  As long as you train the model with a proper [loss function](https://machinelearningmastery.com/how-to-choose-loss-functions-when-training-deep-learning-neural-networks/) for regression the model will learn to output any continuous values, not restricted to and most likely not exactly equal to the labels your providing during training, rather an approximation of them based on the level of generalization the model manage to learn.
  
  The range of values the model can learn to output will also depend on the final activation function of your model. Using a sigmoid is indeed a good choice if your labels belong in the range 0-1.
  
  If instead you don't want the model to learn continuous values then you need to frame the task as a classification problem, and convert your set of finite real values labels into a discrete representation, for example using [one hot encoding](https://machinelearningmastery.com/why-one-hot-encode-data-in-machine-learning/) and then train the model with a loss suited for classification.
  
  
  ---
  
  ### Answer by username_1 on 2022-02-03. Score: 3
  
  Many machine learning models used for regression *will* interpolate their predictions as you seem to want, and can return target values not seen in the training set.
  
  For example, basic linear regression will do this provided at least one of the input variables is also continuous. Also neural networks.
  
  There are some cases where it may not happen:
  
  * Decision tree-based algorithms (such as random forests) approximate with combinations of step functions, so most will output a set of discrete values. However, in practice this set will include many values that are not in the training set, and it is usually not a real concern, if your goal is accurate predictions for unseen data.
  * If all the input features are discrete, then there will be a discrete set of output values, equal in number to all the possible combinations of input. Again, this may not be a practical concern in your case, and will very likely generate outputs that are not in the training set.
  
  
  ---
  
  