In this video, we're going to look at how to use an ends to predict stock prices and stock returns.
Now, normally, I would just say all data is the same.
But there are a few additional details I want to make a note of in this script.
So let's scroll down to where we load in our data.
OK, so for this example, we'll be looking at Starbucks again, there is no special reason for this,
so pick whatever you like.
The next interesting thing we're going to do is standardize the Time series, as you can see, we're
doing this on the column Deflower Close, which is really just the log return.
So why do we want to standardize this data set?
Well, I want to avoid any in-depth mathematical details.
But usually in deep learning, standardizing or normalizing your data is a good idea for intuition.
You can simply test this on various data sets.
What you should observe is that standardization seems to help more often than not.
And again, if you are interested in those details, please see extra reading dot text.
Now, you might also be wondering why do this on the original Time series and not the supervised tabular
data set?
And the reason for this is if you use the tabular data set, it will standardize each column independently,
which won't make much sense.
That will mean the same return as showing up in different columns will have different values.
So instead we would like to standardize the whole time series all at once.
OK, so after selling the log returns, we're going to put them back into the data frame using the column
name scale to log return notice again how we need to flatten the data since I get LERN returns to erase.
The next step is to create a supervised data set, which you know how to do.
The next step is to split our data into train and test.
The next step is to create our and.
So the next few steps are the same as we've seen before.
OK, so here's the last prepack.
Notice how there is Overfitting, which we can observe by looking at the test loss.
The next step is to set the first big test, plus one, values in train reacts to force since they are
unpredictable.
The next step is to obtain the model predictions, so normally we would just call model predict, but
recall that our data has been scaled.
Therefore we need to invert the scaling by calling scale or inverse transform.
The next step is to start predictions.
The next step is do plodder predictions.
OK, so here's a plot of the one step stock return predictions.
Note that it's pretty difficult to see since there are so many values, so you might want to try just
plotting the last few steps.
The next step is to plot the prices will begin by shifting up the log clothes.
The next step is to save the last known train value, although we won't need this just yet.
The next step is to add the previous close price to the predicted returns, since this is just the ones
that forecast, we use the same method for both train and test.
The next step is to plot the one step price predictions, so in order to see things more clearly noticed
that we are only plotting the last 100 steps.
OK, so here's a plot of the one step stock price predictions.
Notice how the model basically just lags the previous value, which is not unexpected.
The next step is to compute the multi-step forecast, since you've seen this code before.
I won't explain it again.
The next step is to invert the scaling on our predictions to do this, we're going to convert our list
of predictions into a Nampara.
We then reshape this to be two dimensional, which is required for Saikat learn.
And then after obtaining the unskilled prediction, we flatten it back to a one Deira.
The next step is to compute the incremental multistep forecast by adding the cumulative some of the
return predictions to the last known price.
The next step is to plot our multi-step forecast.
So as you can see, it comes up to be almost a straight line with a trend, which makes sense, although
it is not a good prediction.
The next step is to create a multi output supervised data set, since you already know how to do this.
I want to explain it again.
The next step is to split our new data into trade and test recall that the test set is only the last
row since that contains our entire forecast horizon.
The next step is to create creator and and to follow the same steps we've already seen before.
The next step is to plot the Los Prepack.
OK, so again, notice that the anend over overfit.
The next step is to plot our model predictions.
OK, so, again, the main difference here is that we need to call inversed Transform to put our predictions
back on the original scale.
The next step is to plot our predictions.
OK, so again, it's pretty much just a straight line with a small trend.
The next step is to check the map.
OK, so notice how the map is actually very small.
This is pretty misleading since, as you recall, airline passengers also has a similar map, and yet
those predictions are actually good predictions.
So you may want to consider a different metric, such as the R-squared.
The next step is to make our problems simpler by doing a one step binary classification.
So in order to build this data set, we can simply use what we had before.
We just need to make new targets by assigning anything above zero to one and anything below zero to
zero.
Notice that our end has exactly the same parameters.
The main difference is that since we're doing binary classification, we use the binary cross entropy
loss.
Also, notice that when we call model Duffett, we use our new targets.
The next step is to check out our laws prepack.
OK, so surprisingly, the Lansberry Park looks pretty good, the Tesla's no longer increases.
The next step is to look at the accuracy prepack.
OK, so notice how even for the test set, which is quite small, we seem to do better than just predicting
a random coin toss.
Of course, the real test is whether or not you can do this consistently.