Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some 'preds' not working #58

Closed
avocardio opened this issue Feb 27, 2021 · 4 comments
Closed

Some 'preds' not working #58

avocardio opened this issue Feb 27, 2021 · 4 comments

Comments

@avocardio
Copy link

When I try to use some preds, I get the same same error for all of them. Don't really know what this means. SMA and arima works fine without problem.

Screen Shot 2021-02-27 at 12 45 49 PM

@DidierRLopes
Copy link
Collaborator

Hey @avocardio , these issues comes from my other module TimeSeriesCrossValidation. And this means that the data you are using to train these models (or "fit" in case of the regressions) is not enough given your number of inputs and number of outputs.

For instance, imagine that you want to predict the share price of Monday using the stock prices of this last week (5 days). You will define the number of outputs to be 1 because you only want to predict 1 share price, and the number of inputs of 5 because you want to use the data of the 5 previous consecutive days.

If when you load the model, you select a starting date -s that starts last week, you won't be able to train because you are using the data that you would be effectively using for prediction. Meaning that you probably need to set that starting date -s for a value more in the past so that you can use that data for training/fitting your model.

Let me know if this makes sense.

TL;DR: Set the starting date flag -s with a value further in the past

@avocardio
Copy link
Author

Makes perfect sense @DidierRLopes , thank you so much. What would be a good time frame for the preds in your opinion? The errors above came from a timeframe starting 2021-01-01.

@DidierRLopes
Copy link
Collaborator

No worries, always happy to help.

Yea that makes sense, by default the algorithm has -i 40 which expects 40 data points. If you are using daily data, this corresponds to 2 months.

There isn't a "right" time frame to use, there are several things that you need to do in order to have one of the Neural Networks optimized for your stock price. Here are some things to look at when doing this:

  • First of all I'd say for you to look at the entire historical data of a stock and try to understand since when up till now the stock has behaved rather similarly. I.e. if you look into the historical data of 20 years ago, probably the stock price didn't move much. So I'd avoid training a model with this.
  • You have to set the training days that you want. Note that that if -i is 40 you are using 40/5= 8 weeks of data = 2 months.
  • You have to set the prediction days, here I'd recommend to set it to 1. As predicting further down in the future is much more complicated, because you have a much larger range to "deviate" from the last valid stock price, if it makes sense
  • You have the model that you want to chose. The models defined per default don't have any guarantees, I just made sure they ran fine, tested a few different ones, and left it like that. Each user must tune it's NN for the stock they want. When I come to implementing Feature request: stock data end date #5 this will be great as it will allow you to "validate" your model. You're gonna be able to test on this past data how your model would work out. And I already have a great idea on how to make this work smoothly, can't wait to implement this.
  • This validation is important because it allows you to set not only your model, but number of training epochs, if data is pre-processed, the optimizer in use, the type of loss function.

Seriously, there's just so much to it. That's the beauty of it.

PS: One thing you can do if you want to not "lose" too much time, is research "successful" papers on stock prediction that disclose how they implemented certain NN (most likely LSTM since this one has a "notion" of time) and just implement it, as the code is written in a way that is really easy to configure a neural network to your own taste!

@avocardio
Copy link
Author

Thanks for the nice explanation, I really appreciate what you're doing with this !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants