From the course: Practical Python for Algorithmic Trading
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
How to train models within the backtest - Python Tutorial
From the course: Practical Python for Algorithmic Trading
How to train models within the backtest
- [Instructor] To create a back test report from an investment strategy where we train the model within the strategy and evaluate on another dataset, we need to modify the init function of the strategy class. The first thing is to declare the decision tree regressor with the max depth of 15 and the random state to be 42, as before. And now we should train the model with self model fit. We need to pass X equals to the X train and Y equals to the Y train. We execute to create the strategies and now at the time to run the back test on a dataset that we need to choose now. And we will choose the X test where we have the required data frame for the back test class. Therefore X test, we set the limit by one, limit cell minus five, with the following lines of code. We get the results, select until the return percentage, change the name of the column, and here we have the report. We do the same on the training back test. Instead of…
Contents
-
-
-
-
-
-
-
(Locked)
Why machine learning models overfit the data4m 21s
-
(Locked)
How to train models within the backtest2m 47s
-
(Locked)
Challenge: Train test with other tickers3m 5s
-
(Locked)
Walk forward validation in machine learning8m 31s
-
(Locked)
Anchored walk forward validation in backtesting5m 36s
-
(Locked)
Create library for backtesting strategies2m 50s
-
(Locked)
Interpret reports from walk forward validation approaches1m 12s
-
(Locked)
Challenge: Walk forward with other tickers5m 2s
-
(Locked)
-