'I need to predict closing value of bitcoin, I really need help (Jupyter)
[In the image you can see what is the error that the code gives, I need to define the "close_price" and the "array"]
import pandas
import numpy
from sklearn.preprocessing import MinMaxScaler
bitcoin_data = pandas.read_csv("BTC-USD.csv", sep=",")
bitcoin_data = bitcoin_data.drop("Date", axis=1)
///////////////////////////////////////////////////////////////////////////
scaler = MinMaxScaler()
scaler.fit(bitcoin_data)
bitcoin_data = scaler.transform(bitcoin_data)
///////////////////////////////////////////////////////////////////////////
def create_dataset(dataset, look_back=1):
dataX, dataY = [], []
for i in range(len(dataset)-look_back-1):
a = dataset[i:(i + dataset)]
dataX.append(a)
dataY.append(dataset[i + look_back])
return numpy.array(dataX), numpy.array(dataY)
frames, target = create_dataset(close_price, 7)
train_size = int(0.90 * frames.shape[0])
train_set, train_labels = frames[0:train_size, :], target[0:train_size]
test_set, test_labels = frames[train_size:, :], target[train_size:]
And this is the error:
IndexError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_9740/728866547.py in <module>
11 train_size = int(0.90 * frames.shape[0])
12
---> 13 train_set, train_labels = frames[0:train_size, :],
target[0:train_size]
14 test_set, test_labels = frames[train_size:, :], target[train_size:]
IndexError: too many indices for array: array is 1-dimensional, but 2
were indexed
Here is the data base: https://query1.finance.yahoo.com/v7/finance/download/BTC-USD?period1=1620524615&period2=1652060615&interval=1d&events=history&includeAdjustedClose=true
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
