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

 
Dr. Trader:

I've already posted examples of neuronics here, I'll look for something suitable and redo it for your data (and with a committee). I won't write introductory lectures, but I'll add more comments to the code.


Sorry, I don't understand the meaning of the variable with(F,T) In the loop.

for(i in c(1:nrow(table))[c(F,T)]){
   ..... table[i,] ..... 
}

So this loop goes on even rows of the table, then how do you do it on odd rows???

 

F and T are abbreviations for boolean values FALSE and TRUE, in principle it does not matter whether to write c(T,F) or c(TRUE,FALSE), the first option is just shorter.

If the table has 10 rows, then c(1:nrow(table)) is just a vector of c(1,2,3,4,5,6,7,8,9,10).
And arrays with boolean values in this case will loop up to the desired length, you get c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE).

i.e. c(1:nrow(table))[c(F,T)] R will understand as
c(1,2,3,4,5,6,7,8,9,10)[c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE)]
and takes those vector elements that match TRUE in order.

For example, if you want to take every third element, you can write it as
c(1,2,3,4,5,6,7,8,9,10)[c(FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE]
or abbreviated
c(1:10)[c(F,F,T)]


For odd elements just swap T and F: c(1:nrow(table))[c(T,F)]

 
Dr. Trader:

F and T are abbreviations for boolean values FALSE and TRUE, in principle it does not matter whether to write c(T,F) or c(TRUE,FALSE), the first option is just shorter.

If the table has 10 rows, then c(1:nrow(table)) is just a vector c(1,2,3,4,5,6,7,8,9,10).
And arrays with boolean values in this case will loop up to the desired length, you get c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE).

i.e. c(1:nrow(table))[c(F,T)] R will understand as
c(1,2,3,4,5,6,7,8,9,10)[c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE)]
and takes those vector elements that match TRUE in order.

For example, if you want to take every third element, you can write it as
c(1,2,3,4,5,6,7,8,9,10)[c(FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE]
or abbreviated
c(1:10)[c(F,F,T)]


For odd elements just swap T and F: c(1:nrow(table))[c(T,F)]

Thank you for not bothering to write such extended descriptions. Really much becomes clear. I'm ashamed to even ask, but I dare. The meaning of the problem is as follows.....

The training file consists of the same number of classes by target. In other words, I have 24 ones and 24 zeros in the target. Again, I want to do like Reshetov.....

I have divided training table into two tables, where one has all vectors where targeting is 1 and the other where targeting is 0.

I take the table with target 1, and then I need to create two subtables, where even numbered vectors are written in Train1, and odd ones in Train2.

First we do it for even numbered ones.

for(i in c(1:nrow(Qwe_true))[c(F,T)]){
  Train1[i,]<-Qwe_true[i,]
  }

But then Train1 table will contain rows c NA, and you need Train1 was the size of 12 lines, because only 12 of 24 rows are even. I have no idea how to do it....

 

Please.

R requires a different way of thinking, you need to mentally operate vectors, then the code is quite simple to write. Professionals write in one line what I don't even understand, and I myself would write cycles in several lines.

Train1 <- rbind(Qwe[which(Qwe[, "target"]==1)[c(T,F)], ], Qwe[which(Qwe[, "target"]==0)[c(T,F)], ])
Train2 <- rbind(Qwe[which(Qwe[, "target"]==1)[c(F,T)], ], Qwe[which(Qwe[, "target"]==0)[c(F,T)], ])

step by step -
which(Qwe[, "target"]==1) - the numbers of lines with target 1
which(Qwe[, "target"]==1)[c(T,F)] - the numbers of lines with target1, skipping through 1
Qwe[which(Qwe[, "target"]==1)[c(T,F)], ] - the table obtained from Qwe, with the target 1 with a space in 1
rbind(... , ...) - merging of two tables (with target 1 and with target 0)

 
Dr. Trader:

Please.

R requires a different way of thinking, you need to mentally operate vectors, then the code is quite simple to write. Professionals write things in one line that I don't even understand, and I myself would write cycles of several lines.

Train1 <- rbind(Qwe[which(Qwe[, "target"]==1)[c(T,F)], ], Qwe[which(Qwe[, "target"]==0)[c(T,F)], ])
Train2 <- rbind(Qwe[which(Qwe[, "target"]==1)[c(F,T)], ], Qwe[which(Qwe[, "target"]==0)[c(F,T)], ])

You're just a monster expert. Two lines, that's a load off your shoulders. All right, I'll keep working on it. Thanks!

 
Friday evening... my head is not good enough. How about checking the theory together....With your ability to write in R and my ability to set the problem (accuracy) we would have checked everything in half an hour already? Is there time? Dr.Trader
 
Nah, keep learning. I'll help you if you have any questions.
 

To these two samples you need to add two more samples.

MLP1=Train1+Test(Train2)

MPL2=Train2+Test(Train1)

If we add up Test(Train2)+Test(Train1), we get the result on the whole training section, and this section will be a test, for each of the polynomial.

Maybe pick a time, if there is no possible now. But it's half an hour and made sure. I just want to do a mirror. I'll take the same file and teach it two ways. Then we'll throw it all on the Control Site and everything will be visible. What do you think?

 

You can combine the tables using the function rbind()
MLP1 <- rbind(Train1, Test)

What is Test(Train2)? And why combine the training and test table? The test should be separate, to test on it already trained model.

It will not come out as easy and fast as you want. In Reshetov's model, you can just feed the data, and the model itself will sift out the predictors, determine the weights, the number of neurons, and so on. With regular neuronics you can't do that, the neuron parameters must be selected through crossvalidation, like in the example I wrote here today, or as in the articles by Vladimir Perervenko.


Look again what I've written there -https://www.mql5.com/ru/forum/86386/page753#comment_6821981
Just paste into that code your data as described, and run it. If predictors are taken all in a row and not sifted out, then from the first time it will probably come out bad. After running the code, run themax(gaResult@fitness) command additionally, this will show the R2 score of the best model found by genetics. If the estimate is close to 1 or a little less then it is good, if it is close to 0 or even negative then it is bad.

Then inPREDICTOR_COLUMNS specify specific numbers of columns that you identified as good, and once again run the code, the model will be trained only on these predictors. Ideally the best model score found by genetics should be close to 1, and the accuracy on the training and on the test table should be 1.00.

The test table - should be in time strictly after the training data, as if this model trades already in the market.

If nothing good comes out of that code (even withKFOLDS=10) - then it's no good. If it works, then there is a good alternative to Reshetov's model and we can further sort out that code and port the model to mql.

 

My point is that if you do something like in Reshetov's model, add something, then take an ordinary neuron and somehow mix it with previous steps, and wait that all this will work like Reshetov's - this will turn out to be a futile long process, which I definitely do not subscribe to.

If you want the same result as Reshetov's, but in R, then you need to rewrite all the java code of the model in R.

But there are many alternatives. If they work even better than Reshetov's - then it's perfect, you don't need anything else, everything is ready.

Reason: