Machine learning in trading: theory, models, practice and algo-trading - page 521

 
Grigoriy Chaunin:

Read about neuron activation functions. You can supply whatever values you want to the output, but the wrong activation function will produce negative values. This is usually a hyperbolic tangent. The softmax loss function will not work correctly with it. Although much depends on the library and the implementation of the loss function. For example in Tensorflow on output neurons for softmax loss function should not have any activation function. And for correct use of trained network it is necessary to add softmax activation.I haven't worked withALGLIB, maybe they did something wrong. In any case, a trained network with softmax should not give negative values.

Softmax is not a loss function. You are confused about something. Softmax is a function of output layer activation for classification tasks. Do not confuse the man, he will get confused himself.

You use Alglib at your own risk. Just do everything in Rstudio.

Good luck

 
Dr. Trader:

This happens if you have a very large number of classes in training examples compared to other classes. For example 2000 training examples for buy and only 1000 for sell. The neuron can always generate "Buy" and will be right in 66% of cases. It is better to make the number of training examples of each class equal.

Class NA - will prevail, from 50% in frequent trading, to 99% in rare trading. But I have it 3rd, and I've got the NA class 1st.

I'm wondering why the articles don't use training examples for moments when you don't have to do anything? Because doing nothing at the right moments is also important, usually those moments are when the trade will lead to a loss.
Without learning to pause, NS may start to trade and lose the deposit.

 
Vladimir Perervenko:

Softmax is not a loss function. You are confused about something. Softmax is a function of output layer activation for classification tasks. Do not confuse the man, he will confuse himself.

You use Alglib at your own risk. Just do everything in Rstudio.

Good luck


To be precise, the loss function is called softmax crossentropy. Yes, I wasn't clear.

 
Vladimir Perervenko:

Softmax is not a loss function. You are confused about something. Softmax is a function of output layer activation for classification tasks. Do not confuse the man, he will confuse himself.

You use Alglib at your own risk. Just do everything in Rstudio.

Good luck

Most likely after your next article (where there will be a connection with the terminal) I will use R as a mapping tool.
 

By the way, it is interesting that from the example above

Buy Sell NA
0.10302356, 0.01091621, 0.88606040
0.09705416, 0.01083526, 0.89211080
0.08283979, 0.12548789, 0.79167247
1.02522414,-0.00119697,-0.02403573
0.09498582, 0.01529507, 0.88971917
1.01878489,-0.00111341,-0.01767998
0.07906346, 0.05960769, 0.86132762
0.00201949, 0.00497863, 0.99300189

The sum of each row is 1. (The top 4 checked). I.e., some analogy to softmax, where the sum (i.e., probability) also = 1. But this was done by NS, a regression with a linear output.

 
elibrarius:

The NA class will prevail, from 50% in frequent trading, to 99% in rare trading.

It is very dangerous to distribute classes to the teacher at random, like taking some indicator to create teacher classes and then replacing part of the values with NA as well.

Even if there are good predictors and good classes to teach and the model holds good results on new data - any attempt to tweak class values can completely break the model. Finding indicators for predictors and an indicator for classes that will keep the model profitable on new data as well is a great stroke of luck.

I would recommend to start with two simple classes - the color of the next bar (i.e. buy/sell). Take at least 10000 training examples (history bar), train the model and evaluate the result on the next 10000 bars in history (that were unknown to the model during training). When you manage to find the predictors that will maintain the accuracy of the model on the same level on the old and new data - you can start to select an indicator for the teacher's classes. And it will turn out that just taking the first available indicator the model will not preserve the accuracy on new data. Why some indicators may serve for the teacher and some may not - I do not know, it is some kind of luck and mystic.

 
elibrarius:

There is something wrong with the SOFTMAX version of NS on ALGLIB. All answers are skewed to the first output (in my case it is BUY).
On the same NS data - regression with 3 outputs (with linear activation) gives more reliable results:

Buy Sell NA
0.10302356, 0.01091621, 0.88606040
0.09705416, 0.01083526, 0.89211080
0.08283979, 0.12548789, 0.79167247
1.02522414,-0.00119697,-0.02403573
0.09498582, 0.01529507, 0.88971917
1.01878489,-0.00111341,-0.01767998
0.07906346, 0.05960769, 0.86132762
0.00201949, 0.00497863, 0.99300189

in >0.5 will give plausible answers.

Lesa, by the way, also skewed on the 1st output.


Did you set the sum of the 2 outputs to one? I don't know, it worked fine for me, no skewing. I liked the softmax.

And yes, as far as I remember for softmax normalized in the range from 0 to 1 inputs

Forests in general always work clearly for regression and classification. There are situations when they do buy or sell only, but then I dug the training set and yes, there was a skew in the examples, so no wonder (because I have them retrain themselves at intervals and I do not know in advance what will be in the set). Also, do not forget that the forests can not extrapolate. You have to train all the values you know in the future.

 

By the way, it doesn't even seem to be necessary:

Data preprocessing

To improve convergence speed and quality of solutions ALGLIB implements preprocessing of data (standardization of training set). Preprocessing is carried out implicitly for the user - before transferring data to the neural network they are automatically pre-processed, the result of network operation is subjected to the reverse transformation.

 

Here is a check of the NS on the multiplication table

I did the same one for scaffolding and it works fine

Библиотеки: ALGLIB - библиотека численного анализа
Библиотеки: ALGLIB - библиотека численного анализа
  • 2012.10.12
  • www.mql5.com
Статьи и техническая библиотека по автоматическому трейдингу: Библиотеки: ALGLIB - библиотека численного анализа
 
Maxim Dmitrievsky:

Did you set the sum of the 2 outputs to one? I don't know, it worked fine for me, without distortion. I liked the softmax.

And yes, as far as I remember for softmax normalized in the range from 0 to 1 inputs

Forests in general always work clearly for regression and classification. There are situations when they do buy or sell only, but then I dug the training set and yes, there was a skew in the examples, so no wonder (because I have them retrain themselves at intervals and I do not know in advance what will be in the set). Also, don't forget that scaffolding cannot extrapolate. It is necessary to train all known values in the future.

I have the sum of 3 outputs=1, or rather not the sum, but only 1 of the outputs =1, the rest=0.
I didn't normalize the inputs, you confirmed below that it is not necessary. I checked the multiplication table (but it's not a softmax).
If softmax worked for you - I'll try to spin it some more, maybe it will work (although on absolutely the same data regression with lin. outputs works as it should).
Reason: