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

 
Aleksey Vyazmikin:

So I was wondering, what if you partition this sample on these islands and already within them do training models.

So you need to apply kmeans clustering or something cooler.

run it

km <- kmeans(um$layout, centers = 4)

that's how many clusters you want to find

and now

as.factor(km$cluster)

put it instead of target


here

 

How beautiful it's become, the pictures.

It's amazing!

keep going gentlemen, watching the process very closely

 
mytarmailS:

So you need to apply kmeans clustering for example or something cooler, wait

run it

How many clusters do you want to find?

and now

put it instead of target


here

I'm doing it wrong :(

> way <- "F:\\FX\\R\\2020_04_11_Pred_New_Full\\Pred_New_Fu ..." ... [TRUNCATED] 

> dt <- read.csv(file = way,header = T,sep = ";") #  читаем файл

> target <- dt$Target_100 #  целевую в отдельную переменную

> #target <- km$cluster #  целевую в отдельную переменную
> 
> dt <- dt[, ! colnames(dt)  %in% 
+            #            c("Target_100_Buy","Target_100 ..." ... [TRUNCATED] 

> km <- kmeans(um$layout, centers = 4)           

> #  роскоментируем и Устанавливаем нужные пакеты после чего эту строку можно удалить
> #install.packages(c("rgl", "car" , "umap"))
> 
> 
> 
> #  про um .... [TRUNCATED] 

> um <- umap(dt,n_components=3)   

> #  n_components=3  во сколько измерений уменьшаем данные, можно 100 можно 1
> #  можно 333, но нам для 3 д надо трех мерное пространство поетому у нас  .... [TRUNCATED] 

> #тут  все настройки по пакету  car
> #  http://www.sthda.com/english/wiki/amazing-interactive-3d-scatter-plots-r-software-and-data-visualization
> lib .... [TRUNCATED] 

> target <- as.factor(target)  #   target нужен для того чтобы окрасить точки в цвет целевой

> scatter3d(x = um.res[,1], 
+           y = um.res[,2], 
+           z = um.res[,3],
+           #groups = target,
+           groups = km$cluster,
+ .... [TRUNCATED] 
Error in scatter3d.default(x = um.res[, 1], y = um.res[, 2], z = um.res[,  : 
  groups variable must be a factor
 
Aleksey Vyazmikin:

I'm doing it wrong :(

scatter3d(x = um.res[,1], 
+           y = um.res[,2], 
+           z = um.res[,3],
+           #groups = target,
+           groups = km$cluster,

throw that out, you can't comment on code within function arguments

 
mytarmailS:

you can't comment on the code inside the function arguments

Wow, took it out and made it like in the screenshot.

scatter3d(x = um.res[,1], 
          y = um.res[,2], 
          z = um.res[,3],
          groups = as.factor(km$cluster),
          grid = FALSE, 
          surface = FALSE,
          ellipsoid = FALSE,
            bg.col = "black")

while it's thinking.

 
Aleksey Vyazmikin:

while he's thinking.

I wonder what))

 
mytarmailS:

interesting about what))


here's a thought, it means managed to split into 4 clusters?

How do I save the line partitioning to each cluster now?

 
Aleksey Vyazmikin:

here's a thought, this means managed to split into 4 clusters?

Yes

Aleksey Vyazmikin:

Now how do you save the line partitioning to each cluster?

You save the umap model.

save the kmeans model

and that's it.



Putellipsoid = TRUE.

should be pretty cool

 
mytarmailS:

Yes

That's interesting, I'll try to learn the models separately and see what happens.


mytarmailS:

save the umap model

save the kmeans model

and that's it.

Can you be more specific?

I need to save:

1. The rules for partitioning into clusters in a readable form, in order to code them in MQL.

2. Layout in clusters of lines in csv file

How do I do it?

 
Aleksey Vyazmikin:


1. The cluster partitioning rules in a readable form, so that they can be coded in MQL


I don't understand, do you want to get the resulting breakdowns in rules and transfer them to mql?