0
$\begingroup$

I am trying to create a neural network for my data which is as follows

Close   label   returns lag_1   lag_2   lag_3   lag_4   lag_5
Date                                
2007-09-26 00:00:00 4940.500000 1   0.000334    0.001348    0.019566    0.018957    0.003212    0.040946
2007-09-27 00:00:00 5000.549805 1   0.012155    0.000334    0.001348    0.019566    0.018957    0.003212
2007-09-28 00:00:00 5021.350098 1   0.004160    0.012155    0.000334    0.001348    0.019566    0.018957
2007-10-01 00:00:00 5068.950195 1   0.009480    0.004160    0.012155    0.000334    0.001348    0.019566
2007-10-03 00:00:00 5210.799805 1   0.027984    0.009480    0.004160    0.012155    0.000334    0.001348
... ... ... ... ... ... ... ... ...
2010-09-24 00:00:00 6018.299805 0   0.009858    -0.005250   -0.003004   0.004782    0.016228    0.009651
2010-09-27 00:00:00 6035.649902 0   0.002883    0.009858    -0.005250   -0.003004   0.004782    0.016228
2010-09-28 00:00:00 6029.500000 0   -0.001019   0.002883    0.009858    -0.005250   -0.003004   0.004782
2010-09-29 00:00:00 5991.299805 0   -0.006336   -0.001019   0.002883    0.009858    -0.005250   -0.003004
2010-09-30 00:00:00 6029.950195 0   0.006451    -0.006336   -0.001019   0.002883    0.009858    -0.005250

For the NN, lag_(1 to 5) are the inputs and label is the output. label can have -1,0 and 1 as values.

My current NN is based on MLPClassifier

from sklearn.neural_network import MLPClassifier
model = MLPClassifier(solver='lbfgs', alpha=1e-5, max_iter=500,
                               hidden_layer_sizes=5 * [10], random_state=1)

It is working as expected and is providing me with the worst results. The only prediction it gives is 0 and rarely any 1 or -1.

Is there any way in which it doesn't predict only -1,0 and 1, but predicts a float value between [-1,1] like 0.123,-0.69,0.420?

If there are other implementations of NN which are better for this situation, then please feel free to use them.

$\endgroup$
0
$\begingroup$

It sounds like you want to use a regression model (which produces a real value as the output, e.g. a value in the range [-1, 1] but possibly outside as well depending on the learning algorithm) instead of a classification model (which produces one of a set of discrete output values based on the training data, e.g. {-1, 0, 1} in your case).

If the code is changed to use MLPRegressor instead of MLPClassifier, it will provide a real value as output.

Instead of:

from sklearn.neural_network import MLPClassifier
model = MLPClassifier(...)

Use:

from sklearn.neural_network import MLPRegressor
model = MLPRegressor(...)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.