|
159 | 159 | " sequence_data.append([np.array(sequences), target])\n", |
160 | 160 | "\n", |
161 | 161 | " # get the last sequence by appending the last `n_step` sequence with `lookup_step` sequence\n", |
162 | | - " # for instance, if n_steps=50 and lookup_step=10, last_sequence should be of 59 (that is 50+10-1) length\n", |
163 | | - " # this last_sequence will be used to predict in future dates that are not available in the dataset\n", |
| 162 | + " # for instance, if n_steps=50 and lookup_step=10, last_sequence should be of 60 (that is 50+10) length\n", |
| 163 | + " # this last_sequence will be used to predict future stock prices not available in the dataset\n", |
164 | 164 | " last_sequence = list(sequences) + list(last_sequence)\n", |
165 | | - " # shift the last sequence by -1\n", |
166 | | - " last_sequence = np.array(pd.DataFrame(last_sequence).shift(-1).dropna())\n", |
| 165 | + " last_sequence = np.array(last_sequence)\n", |
167 | 166 | " # add to result\n", |
168 | 167 | " result['last_sequence'] = last_sequence\n", |
169 | 168 | " \n", |
|
1053 | 1052 | " return accuracy_score(y_test, y_pred)\n", |
1054 | 1053 | "\n", |
1055 | 1054 | "\n", |
1056 | | - "def predict(model, data, classification=False):\n", |
| 1055 | + "def predict(model, data):\n", |
1057 | 1056 | " # retrieve the last sequence from data\n", |
1058 | | - " last_sequence = data[\"last_sequence\"][:N_STEPS]\n", |
| 1057 | + " last_sequence = data[\"last_sequence\"][-N_STEPS:]\n", |
1059 | 1058 | " # retrieve the column scalers\n", |
1060 | 1059 | " column_scaler = data[\"column_scaler\"]\n", |
1061 | 1060 | " # reshape the last sequence\n", |
|
0 commit comments