I was following a YouTube tutorial to learn deep learning (crypto prediction) but I was bombarded with errors. I debugged quite a few of them, but since I'm new to this I really can't figure out a way to solve this.
I get the error:
IndexError: tuple index out of range
on linex_train = np.reshape(x_train, (x_train.shape[0], x_train.shape[1], 1))error traceback: `Traceback (most recent call last): File "/Users/usr/PycharmProjects/cryptoPred/main.py", line 35, in x_train = np.reshape(x_train, (x_train.shape[0], x_train.shape[1], 1)) IndexError: tuple index out of range` `
The full code for context:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pandas_datareader as web
import datetime as dt
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.layers import Dense, Dropout, LSTM
from tensorflow.keras.layers import Lambda
from tensorflow.keras.models import Sequential
# loading data from yahoo financial API
crypto_currency = 'BTC'
rl_currency = 'USD'
start = dt.datetime(2016, 1, 1)
end = dt.datetime(2021, 8, 10)
data = web.DataReader(f'{crypto_currency}-{rl_currency}', 'yahoo', start, end)
# preparing data
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_data = scaler.fit_transform(data['Close'].values.reshape(-1, 1))
prediction_days = 60
x_train, y_train = np.array([]), np.array([])
print(x_train)
for x in range(prediction_days, len(scaled_data)):
x_train = np.append(x_train, scaled_data[x-prediction_days:x, 0])
y_train = np.append(y_train, scaled_data[x, 0])
x_train = np.reshape(x_train, (x_train.shape[0], x_train.shape[1], 1)) // error line