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

 
mytarmailS:

I don't know what you're writing there and how, it's yours, but I need to know that in the target one step out of the future relative to the sample, is this true or not?

It's intricate why so, in the target the result of making a decision on the current line of predictors. I.e. there is no need to shift anything.

 
Aleksey Vyazmikin:

It is intricate why, in the target, the decision result of the current line of predictors. That is, there is no need to shift anything.

In short, everything is as you wanted, even by tuning.

Accuracy : 0.535  
X <- read.csv2("C:\\Users\\....\\Desktop\\test.csv")
Y <- X$Target_100
X <- as.matrix(within(X, rm("Time","Target_P","Target_100",
                      "Target_100_Buy","Target_100_Sell")))
library(glmnet)
tr <- 1:1300 #  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,])

sma <- TTR::SMA(pred,20)
pred2 <- c(pred-sma) ; pred2[pred2>0] <- 1 ; pred2[pred2<=0] <- 0

yy <- tail(Y[-tr] ,200)
pp <- tail(pred2 ,200)
caret::confusionMatrix(as.factor(yy),as.factor(pp))

Throw it away and forget about it.


"Target_P"

Gives 0.97 acurasi

 
Do you teach regression to ones and zeros?
 
Maxim Dmitrievsky:
Do you teach regression to ones and zeros?

So?

 
Почему линейная регрессия не подходит для классификации
  • www.machinelearningmastery.ru
  • www.machinelearningmastery.ru
Статьи, вопросы и ответы на тему: машинное обучение, нейронные сети, искусственный интеллект
 
However, I will not interfere with the gnawing of the granite of the Ministry of Defense.)
 
mytarmailS:

Karoch all done as you wanted, even tuning.

Throw it away and forget it.


gives 0.97 akurasi

I still gives me nothing :) Already more than 20 libraries have demanded to download - I continue, but it is not enough :)

What does this line mean:

tr <- 1:1300 #  train idx

?

 
Maxim Dmitrievsky:
Do you teach regression to ones and zeros?

This idea was expressed by an experienced person - I see no problem checking it out.

 
mytarmailS:

I got this result on a training sample:

          Reference
Prediction  0  1
         0 83 59
         1 17 41
                                          
               Accuracy : 0.62            
                 95% CI : (0.5489, 0.6875)
    No Information Rate : 0.5             
    P-Value [Acc > NIR] : 0.0004225       
                                          
                  Kappa : 0.24            
                                          
 Mcnemar's Test P-Value : 2.563e-06       
                                          
            Sensitivity : 0.8300          
            Specificity : 0.4100          
         Pos Pred Value : 0.5845          
         Neg Pred Value : 0.7069          
             Prevalence : 0.5000          
         Detection Rate : 0.4150          
   Detection Prevalence : 0.7100          
      Balanced Accuracy : 0.6200          
                                          
       'Positive' Class : 0               
                                          

How do I apply the model to another sample/file?

And why are there so few numbers in the contingency table, if I have 4683 rows in the training file, and here I have 83+59+17+41?

And I get it, you submitted the first 200 lines - right?

yy <- tail(Y[-tr] ,200)
pp <- tail(pred2 ,200)

But they seemed to be involved in the training.

 
Aleksey Vyazmikin:

Oh, thank you!

Now let's try to run it :)

I can't install the glmnet package - I can't find it in the repository via R-Studio :(

What to do?

> install.packages("glmnet")
Installing package into ‘C:/Users/User/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
пробую URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/glmnet_4.1-1.zip'
Content type 'application/zip' length 2254744 bytes (2.2 MB)
downloaded 2.2 MB

package ‘glmnet’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
        C:\Users\User\AppData\Local\Temp\RtmpsbZ5ec\downloaded_packages

Install it correctly

Reason: