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

 
Aleksey Vyazmikin:

I have a 4.0.4 requirement for this bible!

where did you read these requirements?

 
mytarmailS:

Where did you read these requirements?

When I ran the script, I got an error that the version required was

Warning message:
пакет ‘glmnet’ был собран под R версии 4.0.4 
 
Aleksey Vyazmikin:

When running the script, it gave an error that the version required is

Hz here are the requirements

Version:        4.1-1
Depends:        R (≥ 3.6.0), Matrix (≥ 1.0-6)
Imports:        methods, utils, foreach, shape, survival
Suggests:       knitr, lars, testthat, xfun, rmarkdown
Published:      2021-02-21

You must have a version less than 3.6.0

 
mytarmailS:

Ahahahaha, the expert comparator ))))

Go on, talk about DSP ))))

Need more facepalms )))))))))))

What's there to argue or argue about... been there, done that.

 
mytarmailS:

Hz here are the requirements

You must have a version less than 3.6.0.

I have different versions, but there was 4.0.2.

Can you add the ability to directly download the sample file - file attached? I understand that you need two files for training and for applying the model?

Target "Target_100".
Files:
test.zip  937 kb
 
Aleksey Vyazmikin:

I have different versions, but there was 4.0.2.

Can you add the ability to directly download the file with the sample - file attached? I understand that you need two files for training and for applying the model?

Target_100.

Are the targets shifted back a step? Or do they need to be shifted?


It looks like it needs to be shifted...

X <- read.csv2("C:\\Users\\..........\\Desktop\\test.csv")
Y <- X$Target_P
X <- as.matrix(within(X, rm("Time","Target_P","Target_100",
                      "Target_100_Buy","Target_100_Sell")))
Y <- c(Y[-1],1)

library(glmnet)
tr <- 1:1000 #  train idx

best_lam <- cv.glmnet(x = X[tr,], 
                      y = Y[tr],alpha = 1, 
                      lambda = 10^seq(2, -2, by = -.1), 
                      nfolds = 5)$lambda.min


lasso_best <- glmnet(x = X[tr,], y = Y[tr], alpha = 1, lambda = best_lam)
pred <- predict(lasso_best, s = best_lam, newx = X[-tr,])


pred2 <- c(sign(pred))
caret::confusionMatrix(as.factor(pred2),as.factor(Y[-tr]))
Confusion Matrix and Statistics

          Reference
Prediction  -1   1
        -1 215 142
        1   76 128
                                         
               Accuracy : 0.6114      


The usual junk, like everything else...

 
mytarmailS:

Are the targets moved back a step? Or do they need to be moved?

This is a ready sample, you don't need to move anything.

You just need to filter the columns.

Time Target_P
Target_100_Buy Target_100_Sell
 
Aleksey Vyazmikin:

It's a ready sample, you don't have to move anything.

Did you move it?

Did you move it again?

 
mytarmailS:

Did you shift?

Why would I shift, I have predictors written on the event, when the next event occurs, the result is written to the previous line, including in the form of a class.

 
Aleksey Vyazmikin:

Why do I need to shift, I have predictors written on the event, when the next event occurs, the result is written to the previous line, including in the form of a class.

I do not know what you're there and how you write it, it's yours, but I need to know that in the Target value from the future one step relative to the sample, THIS IS IT or NOT?