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

 
elibrarius #:
If only 1 and 2 can interact. Or 3,4,5. Then after the first split, for example on 3, all downstream splits will be only from set 3,4,5.
I assume that simply builds 2 trees from 1,2 and from 3,4,5 sets. If there are 10 sets, then there are 10 trees. And so on.

It is also possible to merge groups into groups - you get a tree (list of lists of lists of lists of lists ...).

The general principle of building such groups in our case is not quite clear.

 
Aleksey Nikolayev #:

Working on it. No grail yet.)

Are you mastering the grammEvol package?

 
mytarmailS #:
Are you getting the grammEvol package?

gramEvol? If in terms of grammars, you need parametric grammars, where the rules have numeric parameters to be optimised for. At first glance I didn't see them in the package. I mean to get not only rules x1-x2*x3<0, but all possible rules of the form A<x1-x2*x3<B, where x1, x2, x3 are predictors, A and B are parameters.

No, I'm fiddling at the lowest level - with Rcpp, trying to find the right maths.

 
Aleksey Nikolayev #:

Didn't see them in the package at first glance.

Everything is there. Everything you can think of can be implemented there.

Look at the examples from the vignettes, look at the author's gthub in the questions, I asked a lot of questions about the rules there too
 
mytarmailS #:
Everything is there. Anything you can think of can be realised there.

Look at examples from the vignettes, look at the author's gthub in the questions, I asked a lot of questions about the rules there too

Thanks, I'll have a closer look when I have time.

 
Aleksey Nikolayev #:

Thanks, I'll take a closer look when I have time.

This is actually a code constructor, you only set the elements you need.

That is, it can write real code itself, with cycles, arrays, everything, everything....

And since it can write code, it can write anything, the only limit is your imagination, well, and deductive power of course.

 
Aleksey Nikolayev #:

gramEvol? If in terms of grammars, we need parametric grammars, where the rules have numeric parameters to be optimised for. At first glance I didn't see them in the package. I mean to get not only rules x1-x2*x3<0, but all possible rules of the form A<x1-x2*x3<B, where x1, x2, x3 are predictors, A and B are parameters.

No, I'm fiddling at the lowest level - with Rcpp, trying to find the right maths.

I don't know if I understood you correctly, I wrote a simple example by banging my head against the monitor a little bit.

library(gramEvol)
ruleDef <- list(
  logyc_exp     = grule(comparison(big_math_expr, parameters)),
  comparison    = grule(">=","<=","!=","=="),
  parameters    = grule(100,200,300),  #   A и B - параметры.
  
  
  big_math_expr = grule( math_expr,  math_oper(math_expr, math_expr)),
  math_expr     = grule(math_oper(predictors, predictors)),
  math_oper     = grule("+", "-", "*","/"),
  predictors    = grule(x1,x2,x3,x4) #   где x1, x2, x3 - предикторы
  )

grammarDef <- CreateGrammar(ruleDef)
GrammarRandomExpression(grammarDef,numExpr = 10)

Is that what you wanted?

[[1]]
expression(x4 * x1 + (x2 + x4) <= 100)

[[2]]
expression(x1/x3 * (x4/x1) >= 300)

[[3]]
expression(x2/x1 + x1 * x1 != 300)

[[4]]
expression(x4 - x3 + (x3 + x1) != 100)

[[5]]
expression(x2/x1/(x2 + x1) != 300)

[[6]]
expression(x3/x1 + (x3 + x3) >= 100)

[[7]]
expression(x1 * x1 >= 200)

[[8]]
expression(x3/x2 - x3/x2 <= 100)

[[9]]
expression((x3 + x4)/(x4 - x1) <= 300)

[[10]]
expression(x3/x1 <= 200)
 
mytarmailS #:

I don't know if I understood you correctly, I wrote a simple example after beating my head against the monitor a little bit.

Is that what you wanted?

It looks like it, but it seems that parameters can only take a few specified values, not an arbitrary real number.

 
Aleksey Nikolayev #:

Similar, but it seems that parameters can only take a few given values, not an arbitrary real number.


my_var <- round(seq(-10,10,length.out = 100),2)

library(gramEvol)
ruleDef <- list(
  logyc_exp     = grule(comparison(big_math_expr, parameters)),
  comparison    = grule(">=","<=","!=","=="),
  #parameters    = grule(100,200,300),  #   A и B - параметры.
  parameters    = do.call(gsrule, as.list(my_var)),  #   A и B - параметры.
  
  
  big_math_expr = grule( math_expr,  math_oper(math_expr, math_expr)),
  math_expr     = grule(math_oper(predictors, predictors)),
  math_oper     = grule("+", "-", "*","/"),
  predictors    = grule(x1,x2,x3,x4) #   где x1, x2, x3 - предикторы
)

grammarDef <- CreateGrammar(ruleDef)
GrammarRandomExpression(grammarDef,numExpr = 10)
[[1]]
expression(x1 - x2 != 9.6)

[[2]]
expression(x3 + x1 != 9.8)

[[3]]
expression(x2 - x1 - x1 * x1 == 9.8)

[[4]]
expression(x4/x3 - (x2 - x3) != 8.59)

[[5]]
expression(x4 + x2 >= -8.18)

[[6]]
expression((x1 - x4)/(x3 * x2) <= 6.57)

[[7]]
expression(x2 - x1 >= 1.92)

[[8]]
expression(x1 * x3 + x3/x4 != -2.93)


Is that better?


=====================

You can also complicate the expressions

library(gramEvol)
ruleDef <- list(
  
  final_exp     = grule(logyc_exp , logyc_exp | logyc_exp , logyc_exp & logyc_exp),
  
  
  logyc_exp     = grule(logyc_oper(big_math_expr, parameters),
                        logyc_oper(big_math_expr, big_math_expr)),
  
  
  logyc_oper    = grule(">=","<=","!=","=="),
  parameters    = do.call(gsrule, as.list(my_var)),  #   A и B - параметры.
  
  
  big_math_expr = grule( math_expr,  math_oper(math_expr, math_expr)),
  math_expr     = grule(math_oper(predictors, predictors)),
  math_oper     = grule("+", "-", "*","/"),
  predictors    = grule(x1,x2,x3,x4) #   где x1, x2, x3 - предикторы
)

grammarDef <- CreateGrammar(ruleDef)
GrammarRandomExpression(grammarDef,numExpr = 10)
[[1]]
expression(x3 * x2 <= x2 * x3 - (x4 - x4))

[[2]]
expression(x2/x1 != x3 - x1 | (x1 + x3)/(x1 * x3) >= -9.6)

[[3]]
expression(x4 + x3 - (x2 - x2) >= 3.94 & x3 * x2 * (x1 - x3) == x2 * x1)

[[4]]
expression(x3 * x3 - x2 * x4 == -6.97)

[[5]]
expression(x4 * x4 - (x1 + x4) <= x4/x4 - x3/x2 | (x3 + x1)/(x4 - x1) >= x2 * x3)

[[6]]
expression(x2 + x3 + x2/x1 != -3.74)

[[7]]
expression((x1 - x2)/(x2 + x1) <= (x3 - x3)/(x2 - x1) & x4/x2 - x4 * x2 <= 6.97)
 
mytarmailS #:



Is that better?


=====================

you can further complicate the expressions

Yeah, the list thing is a good idea.

To make a real double, you need algebraic data types. I haven't seen their implementation for R yet, and genetic optimisation won't work with them( it's not clear what kind of optimisation will work with them atall).

Reason: