I have X values and corresponding y-labels, until now I used to round my labels <0.5 to 0 and >0.5 to 1. Is it possible to use values between 0 and 1 for "y train"? Using Keras and Tensorflow. Appreciate any suggestions.
3 Answers
Assuming y_train
is already in range [0, 1], it should be enough to specify the correct loss function while compiling a model (model.compile).
Loss functions can be found here.
Chose one which is not for categorical variables (since you have a range [0, 1]).
First, what you need to consider is not whether you can or not, but whether your practice so far or what you are planning to do make sense for your use-cases. Basically choose whichever make more sense for your use-cases.
After you decide, now for your question, It is very possible. The next thing you want to consider is what loss function to use. Note that contrary to what you might think crossentropy loss still make sense for this case.
You are talking about 2 different optimization problems and would know best which of the 2 is your case.
In the first case you are trying to divide the data to 2 distinctive categories - classification (using 0,1 labels), and in the second you are trying to estimate the relationship between the input and the output variables - regression (using the [0,1] range).
For the first category you should use binary cross-entropy (keras.losses.binary_crossentropy)
For the second you should use MSE (keras.losses.mean_squared_error).
These are just 2 of the available options, you can read about more options in the following link: How to choose the right loss for fitting a model