From b3f863228bdc735e9eb5c8d4740fb9a0e575b449 Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 14 May 2021 15:35:33 -0400 Subject: [PATCH] update readme --- .../FUNE-TUNING-NN-models.md | 24 ++++++-- .../prediction_techniques/README.md | 56 ++++++++++++------- 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/gamestonk_terminal/prediction_techniques/FUNE-TUNING-NN-models.md b/gamestonk_terminal/prediction_techniques/FUNE-TUNING-NN-models.md index ad4ab6bab15..e3189b8163c 100644 --- a/gamestonk_terminal/prediction_techniques/FUNE-TUNING-NN-models.md +++ b/gamestonk_terminal/prediction_techniques/FUNE-TUNING-NN-models.md @@ -16,7 +16,17 @@ load MSFT -s 2014-01-01 3. **Out of this training data, select which part will be used for validation** -Since this is a timeseries, and the data has a sequence, the data at the end of the timeseries is the one to be used for validation. As a rule of thumb I usually try to "steal" the least amount of data from the training set, since the more recent the data the more important it is for training. Hence, one could set the end date of training data to be the current day - days of predictions. +Anyone reading this, note this is quite a discussion between the devs. Since this is a time series, there is an inherent +ordering of the data. However, since returns are random, it is hard to predict, and ordering data may not have any meaning. + +To this end, we allow users to specify how much validation data to use and if it should be shuffled. By default, we will split +into 10% validation data with a random shuffle. This will allow the user to see how the model performs at various times in your sequence. + +``` +-v/--valid : validation split of data. Deafult 0.1 (10%) +--no_shuffle : Flag that will order the validation data so that the last (-v) percent of data is the validation. +``` +To try "backtesting" to a certain data, you can specify the end date. This will forecast and compare the true data from that time. ``` -e/--end : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. ``` @@ -25,7 +35,7 @@ Since this is a timeseries, and the data has a sequence, the data at the end of Decide whether you want to pre-process your share price data or not. I.e. do you want to use these values between 18 and 245, or perhaps normalize these between 0 and 1? The later may improve performance. ``` --p/--pp : pre-processing data. Default normalization. +-p/--pp : pre-processing data. Default minmax. ``` 5. **Select input, prediction days and jumps in training data** @@ -91,14 +101,20 @@ This model is set in [config_neural_network_models.py](/config_neural_network_mo -l/--loss : loss function. Default mae. ``` -**Optimizer technique**: Adaptive Moment Estimation (_adam_) is usually the default choice for this type of problems. See https://www.tensorflow.org/api_docs/python/tf/keras/optimizers. +**Optimizer technique**:Adaptive Moment Estimation (_adam_) is usually the default choice for this type of problems. See https://www.tensorflow.org/api_docs/python/tf/keras/optimizers. + +The optimizer selection has been moved to teh config_neural_network_models.py file and the new argument is the learning rate. +This tells your model how "fast" to train by adjusting the factor that gets multiplied to the loss function for updating weights ``` --o/--optimizer : optimization technique. Default adam. +--lr : learning rate. Default 0.01. ``` 9. **Training epochs** Select the number of epochs to train your model. The bigger number of epochs, the longer the training will take, and also increase chances of overfitting. + +An early stopping has been implemented that will (if desired) stop training once the validation loss has plateaued. the patience (number of +epochs with no improvement) can be found in the config file. ``` --epochs : number of training epochs. Default 200. ``` diff --git a/gamestonk_terminal/prediction_techniques/README.md b/gamestonk_terminal/prediction_techniques/README.md index 4646140a780..cd4ddda2b02 100644 --- a/gamestonk_terminal/prediction_techniques/README.md +++ b/gamestonk_terminal/prediction_techniques/README.md @@ -2,8 +2,6 @@ This menu aims to predict the share price of a pre-loaded stock, and the usage of the following commands along with an example will be exploited below. See [How to fune-tuning a NN model](FUNE-TUNING-NN-models.md). - * [sma](#sma) - - simple moving average * [ets](#ets) - Exponential Smoothing (e.g. Holt-Winters) * [knn](#knn) @@ -28,6 +26,8 @@ This menu aims to predict the share price of a pre-loaded stock, and the usage o * [lstm](#lstm) - Long-Short Term Memory - Contains a [backtesting example](#backtesting) + * [conv1d](#conv1d) + - 1D Convolutional Neural Net **Note:** _Use this at your own discretion. All of these prediciton techniques rely solely on the closing price of the stock. This means that there are several factors that the models aren't aware of at the time of prediction, and may - drastically - move the price up or down. Examples are: news, analyst price targets, reddit post, tweets from Elon Musk, and so on._ @@ -35,17 +35,6 @@ This menu aims to predict the share price of a pre-loaded stock, and the usage o -## sma -``` -usage: sma [-l N_LENGTH] [-d N_DAYS] -``` -Simple Moving Average: - * -l : length of SMA window. Default 20. - * -d : prediciton days. Default 5. - * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. - -![sma](https://user-images.githubusercontent.com/25267873/108604945-d29aea80-73a8-11eb-8dac-6a545b9c52b9.png) - ## ets ``` usage: ets [-t TREND] [-s SEASONAL] [-p SEASONAL_PERIODS] [-d N_DAYS] @@ -154,7 +143,7 @@ Facebook's Prophet: ## mlp ``` usage: mlp [-d N_DAYS] [-i N_INPUTS] [-j N_JUMPS] [--epochs N_EPOCHS] [-p {minmax, normalization,standardization,none}] -[-o {adam,adagrad,adadelta,adamax,ftrl,nadam,optimizer,rmsprop,sgd}] [-l {mae,mape,mse,msle}] [-e S_END_DATE] [--loops N_LOOPS] + [-l {mae,mape,mse,msle}] [-e S_END_DATE] [--loops N_LOOPS] [-v VALID] [--lr LEARNING_RATE] [--no_shuffle] ``` MulitLayer Perceptron: * -d : prediciton days. Default 5. @@ -162,14 +151,16 @@ MulitLayer Perceptron: * -j : number of jumps in training data. Default 1. * --epochs : number of training epochs. Default 200. * -p : pre-processing data. Default minmax. - * -o : optimization technique. Default adam. + * -v : validation split. Default 0.1 * -l : loss function. Default mae. * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. * --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). * --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). * --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. * --batch_size: batch size for model training, should not be used unless advanced user. Default None. + * --lr : learning rate for optimizer * --loops: number of loops to iterate and train models. Default 1. + * --no_shuffle : split validation data in time_ordered way instead of random. Due to the complexity of defining a model through command line, one can define it in: [config_neural_network_models.txt](/config_neural_network_models.py) ``` @@ -191,7 +182,7 @@ MultiLayer_Perceptron \ ## rnn ``` usage: rnn [-d N_DAYS] [-i N_INPUTS] [-j N_JUMPS] [--epochs N_EPOCHS] [-p {normalization,standardization,none}] -[-o {adam,adagrad,adadelta,adamax,ftrl,nadam,optimizer,rmsprop,sgd}] [-l {mae,mape,mse,msle}] [-e S_END_DATE] [--loops N_LOOPS] + [-l {mae,mape,mse,msle}] [-e S_END_DATE] [--loops N_LOOPS] [-v VALID] [--lr LEARNING_RATE] [--no_shuffle] ``` Recurrent Neural Network: * -d : prediciton days. Default 5. @@ -199,7 +190,7 @@ Recurrent Neural Network: * -j : number of jumps in training data. Default 1. * --epochs : number of training epochs. Default 200. * -p : pre-processing data. Default normalization. - * -o : optimization technique. Default adam. + * -v : validation split. Default 0.1 * -l : loss function. Default mae. * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. * --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). @@ -207,6 +198,8 @@ Recurrent Neural Network: * --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. * --batch_size: batch size for model training, should not be used unless advanced user. Default None. * --loops: number of loops to iterate and train models. Default 1. + * --lr : learning rate for optimizer + * --no_shuffle : split validation data in time_ordered way instead of random. Due to the complexity of defining a model through command line, one can define it in: [config_neural_network_models.txt](/config_neural_network_models.py) ``` @@ -235,7 +228,7 @@ Recurrent_Neural_Network \ ## lstm ``` usage: lstm [-d N_DAYS] [-i N_INPUTS] [-j N_JUMPS] [--epochs N_EPOCHS] [-p {normalization,standardization,none}] -[-o {adam,adagrad,adadelta,adamax,ftrl,nadam,optimizer,rmsprop,sgd}] [-l {mae,mape,mse,msle}] [-e S_END_DATE] [--loops N_LOOPS] + [-l {mae,mape,mse,msle}] [-e S_END_DATE] [--loops N_LOOPS] [-v VALID] [--lr LEARNING_RATE] [--no_shuffle] ``` Long-Short Term Memory: * -d : prediciton days. Default 5. @@ -243,14 +236,16 @@ Long-Short Term Memory: * -j : number of jumps in training data. Default 1. * --epochs : number of training epochs. Default 200. * -p : pre-processing data. Default normalization. - * -o : optimization technique. Default adam. + * -v : validation split. Default 0.1 * -l : loss function. Default mae. * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. * --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). * --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). * --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. * --batch_size: batch size for model training, should not be used unless advanced user. Default None. - * --loops: number of loops to iterate and train models. Default 1. + * --loops: number of loops to iterate and train models. Default 1 + * --lr : learning rate for optimizer + * --no_shuffle : split validation data in time_ordered way instead of random. Due to the complexity of defining a model through command line, one can define it in: [config_neural_network_models.py](/config_neural_network_models.py) ``` @@ -273,3 +268,24 @@ Long_Short_Term_Memory \ Captura de ecrã 2021-03-14, às 00 06 51 +## conv1d +``` +usage: lstm [-d N_DAYS] [-i N_INPUTS] [-j N_JUMPS] [--epochs N_EPOCHS] [-p {normalization,standardization,minmax,none}] + [-l {mae,mape,mse,msle}] [-e S_END_DATE] [--loops N_LOOPS] [-v VALID] [--lr LEARNING_RATE] [--no_shuffle] +``` +1D Convolutional Neural Net: + * -d : prediction days. Default 5. + * -i : number of days to use for prediction. Default 40. + * -j : number of jumps in training data. Default 1. + * --epochs : number of training epochs. Default 50. + * -p : pre-processing data. Default minmax. + * -v : validation split. Default 0.1 + * -l : loss function. Default mae. + * -e : end date (format YYYY-MM-DD) of the stock - Backtesting. Default None. + * --xla_cpu: if present, will enable XLA for CPU (overrides environment variables during run). + * --xla_gpu: if present, will enable XLA for GPU (overrides environment variables during run). + * --force_allow_gpu_growth: if true, will force TensorFlow to allow GPU memory usage to grow as needed. Otherwise will allocate 100% of available GPU memory when CUDA is set up. Default true. + * --batch_size: batch size for model training, should not be used unless advanced user. Default None. + * --loops: number of loops to iterate and train models. Default 1. + * --lr : learning rate for optimizer + * --no_shuffle : split validation data in time_ordered way instead of random. \ No newline at end of file