Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to train and test Machine Learning models

Hi all,
I read carefully the thread Machine Learning on Quantopian threads and I had a look at the algorithms as well.
I have a couple of questions that are both methological and practical.
A possible testing strategy is to alternate train and test phases for a long period of time (e.g. from 1991 to 2010), in order to have the model experiencing different market conditions. So we can train a model for a fixed time window (say 100 days for instance) then build a portfolio, hold it for a period (e.g. one week) , then re-train the model for a shifted period of time and so on, in order to cover all the wide time span 1991-2010.
1. I believe this is something that can be achieved with Quantopian on the backtesting environment, right? Or we may experience perfomance problems? After all we'll be training the classifier with few data, so the process should take some time but I shouldn't experience out-of-memory problems
2. Here's the question (maybe a naive one, so forgive me): let's imagine I'm happy with the performance of the model I've trained with the approach of point 1, how can I move the same model into production (with live data or in paper trading mode)?
Thanks a lot !
Giovanni

1 response
  1. First note that Quantopian's data source only goes back to Jan 2, 2002. What you are proposing is certainly possible, though your model's parameters may be somewhat volatile over such a long period of time. The advantage of this is that it is self-adjusting, but the disadvantage of this is that the model will have to be implemented into the algorithm itself (which may cause memory problems depending on the complexity of the model).

An alternative method is to train/test the model in Research with a shorter period of time (e.g. last 2 years) but larger time window (full 2 years instead of 100 days) and use only the outputs in the algorithm itself. The advantage of this is that you have much more data to work with, which can lead to better model performance, but the model's parameters remain static as time passes. So there is a trade-off here.

  1. Following the approach you proposed, you'd end up with a set of different models for different time periods. If possible, implementing the actual training/testing into the algorithm would be ideal (i.e. doing computations within before_trading_start() ).