2
$\begingroup$

I have data from CoinMarketCap for the close prices of Bitcoin. How can I use this data to predict multiple days into the future using past days with a function? I want the function to look like:

def predict(days, data):
  preds=data[-days*2:]
  for d in days:
     pred=model.predict(preds)
     preds.append(pred)
  return np.array(preds)

I already have a train-test split function and window converter. My input data's shape is (*,1) and thus to loop this I need my output to have the exact shape.

How can I do this and what will my model look like in Keras? Do I have to convert the data into windows?

This is my code so far:

window_len=30

def train_test_split(df, test_size=0.1):
    split=len(df) - int(test_size * len(df))
    train=df[:split]
    test=df[split:]
    return train, test

def pred_convert_window(df,window_len=window_len):
    windows=[]
    for i in range(len(df)-window_len):
        windows.append(df[i:i+window_len])
    return np.array(windows)

# PRED MODEL IN/OUT
scaler=MinMaxScaler(feature_range=(0,1))
close=scaler.fit_transform(df['close'].values.reshape(-1,1))

train,test=train_test_split(close)

My close data shape is (2022,1)

My train and test data shapes are ((1820, 1), (202, 1))

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.