# Binary classification for variable outputs

I am creating a binary classifier in Keras and here's the code

model = Sequential()


The problem though, is that I have variable targets, i.e. they lie between -1 and 1. And here is a histogram of the distibution of my targets

I know that this still, could work very well for me, and the model would probably be able to predict the variable outputs, the input data is very complex, and the model might not be able to train to predict the exact outputs. I am perfectly okay of the model cannot predict the exact values, as a long as the sign of the output [-1,1] is correct.

So I thought what if the loss function gave zero loss for a prediction that has the correct sign, but gave whatever the required binary loss is, if the output has the wrong sign, this way, during training it would give importance to the highly incorrect predictions, but as soon as the sign of the predictions are right (just what I need), it doesn't consider them anymore, hopefully giving a better result. The catch here is, that if I just trained it to predict the signs of the targets, it would give all of the inputs equal importance

So my question is, does any such loss function exist in Keras or anywhere else, or do I have to create my own loss function? If I have to create my own loss function, how do I do it?

Actually what you need is a linear regression model and not a binary classifier. You can trying to predict continuous variables using a classifier. So we need to build a regression model which predicts continuous variables in a range i.e from -1 to 1.

You can do this with some changes in your code.

model = Sequential()

Instead of accuracy as the metric, use mae or mean absolute error to monitor the model's progress.