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

 
anonymous:

and transpose as needed depending on matrix dimension

Just use two functions kohonen::classvec2classmat, kohonen::classmat2classvec. You can just copy those functions to yourself and use them as needed.

> classvec2classmat
function (yvec) 
{
    if (!is.factor(yvec)) 
        yvec <- factor(yvec)
    nclasses <- nlevels(yvec)
    outmat <- matrix(0, length(yvec), nclasses)
    dimnames(outmat) <- list(NULL, levels(yvec))
    for (i in 1:nclasses) outmat[which(as.integer(yvec) == i), 
        i] <- 1
    outmat
}
> classmat2classvec
function (ymat, threshold = 0) 
{
    class.names <- dimnames(ymat)[[2]]
    if (is.null(class.names)) 
        class.names <- 1:ncol(ymat)
    classes <- apply(ymat, 1, function(x) which(x == max(x))[1])
    classes[apply(ymat, 1, max) < threshold] <- NA
    factor(class.names[classes], levels = class.names)
}

Good luck

 
elibrarius:

Another problem with R.

On one computer everything is fine, on the other one there are some increased requirements for the correctness of the code.

For example

darch.unitFunction = linearUnit - caused Rterm.exe to crash

changed it to

darch.unitFunction ="linearUnit"

this point began to pass before the next error.

I also had to change library(darch) to require(darch)

Now it's the learning itself that's a bummer.

R_NN <- darch(
darch = NULL,
x = MatrixLearnX ,
y = MatrixLearnY ,
paramsList = params
)

I tried many variants, Rterm.exe always crashes

Does R have some kind of error level control? Maybe on the second PC I ended up with an error level to work out when stopping at every warning?

I installed R on both computers with default settings, I installed all the packages.
How do I fix it?

Take a snapshot of the session on one and the other PC and compare them. For example

> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils    
[5] datasets  methods   base     

other attached packages:
[1] kohonen_3.0.4        RevoUtils_10.0.6    
[3] RevoUtilsMath_10.0.1

loaded via a namespace (and not attached):
[1] MASS_7.3-47    compiler_3.4.2
[3] tools_3.4.2    Rcpp_0.12.13  

good luck

 
Vladimir Perervenko:

Take a snapshot of the session on one computer and the other and compare them. For example

good luck

Not by that method, but I figured it out, rather by trial and error.
Thank you

 

By the way, I met here the expression "hardcode" network.
Apparently it is to get a function with weights and offsets and calculate outputs.

For example, how to get weights from darch for first layer: print(NN@layers[[1]]$weights)

Is there any ready-made script to create such a hardcoded function?

 

Made basic functionality for cryptocurrency trading through R. The crypto exchange is bittrex, I used to pass all checks there, so now I can check the code in action right away.
In code you need to replace API_KEY and API_SECRET values with what exchange will give you personally in profile settings.

Less of this exchanger - their api have no functions to get ohlc values, the ticks you need to collect yourself and build ohlc bars (or download them from a third party resource). And for access to the api and trolling through it (and through R) need to pass identity verification, and activate 2fa.

Probably should find an exchange that gives out ohlc via api, and does not require identity verification to trade, all exchanges work with api in general is similar, this script can be easily remade for another.

 
Maxim Dmitrievsky:

But yes, 90% of it is datamining 10% model selection

+100!
 
Yuriy Asaulenko:

So you will soon have to start a mining farm for mining strategies.


Well, now the situation is this: the bot that I have done before is very cool optics at a small distance, on the forward is working 50/50, ie if the market has not changed, fires in the +, if changed, minus. It can be modified, more Reshetov's neurons can be squeezed in, or there is a version based on fuzzy logic, it is even more abrupt, but it increases optimizable weights ... i.e. basically, if I train it in the cloud and pay about ... I don't know ... 100 bucks for it, it should probably last a long time and bring good profit, but I am not mentally ready for such long trainings. The second variant is a self-optimizing system, it is not ready yet, it will retrain itself without the optimizer. I like this variant more, but it is not clear yet :)

 
Maxim Dmitrievsky:

Well, now the situation is as follows: the bot that I made before is very cool optimized at a small distance, on the forward side it works 50/50, i.e. if the market has not changed, it is +, if it has changed, it is minus. It can be modified, more Reshetov's neurons can be squeezed in, or there is a version based on fuzzy logic, which is even more abrupt, but it increases optimizable weights ... i.e. basically, if I train it in the cloud and pay about ... I don't know ... 100 bucks for it, it should probably last a long time and bring good profit, but I am not mentally ready for such long trainings. The second option is a self-optimizing system, it's not ready yet, it will retrain itself without the optimizer... I like this variant better, but it is not clear yet :)

I do not understand, what is the optimizer?

When I hear "optimizer" I have a bad association with a MT tester-optimizer.

 
Yuriy Asaulenko:

I do not understand what is the optimizer?

When I hear optimizer, I have a bad association with a tester-optimizer MT.


Yes, why not good? MO is in fact optimization before AI was invented.

Genetics is also an MO

 
Maxim Dmitrievsky:

Yes, why not good? MO is essentially optimization until AI is invented.

Genetics is also a part of AI.

The criteria are important in "optimization". Optimization by maximal profit is not a very good criterion. At the same time there is no reason to believe that it will somehow work in the future, which we often see in practice, on the forum in particular.
Reason: