ageron / ageron/handson-ml2

The source code on github for Chapter 15 may have some inconsistency

Open
#214 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
30k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

I was following the examples in chapter 15 and found that there may be some inconsistency in predicting future values.
In cell 24, the following code is used in making prediction:
for step_ahead in range(10):
y_pred_one = model.predict(X[:, step_ahead:])[:, np.newaxis, :]
X = np.concatenate([X, y_pred_one], axis=1)

I believe that we are feeding the model with an input vector of 50 features, as we concatenate y_pred_one to X, we slide the feature input using X[:, step_ahead:] and keep its size at 50.

But in cell 28, which uses the same model, the source code is:
for step_ahead in range(10):
y_pred_one = model.predict(X)[:, np.newaxis, :]
X = np.concatenate([X, y_pred_one], axis=1)

In this snippet, the size of input X is increasing as we concatenate y_pred_one to it. I checked the outputs (with sliding the input set and w/o sliding it), they are different.
My question is which one is correct? And why?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.