implement into this code coingecko API to get the historical ethereum price data from…
- User
implement into this code coingecko API to get the historical ethereum price data from 1/1/2014 until today, it will automatically update for present say, for # Import libraries import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, LSTM, RNN
Load Bitcoin price data
bitcoin_df = pd.read_csv('/content/bitcoin_prices.csv', index_col='Date')
Preprocess data
scaler = MinMaxScaler() bitcoin_scaled = scaler.fit_transform(bitcoin_df)
Split data
X_train, y_train = bitcoin_scaled[:2000], bitcoin_scaled[1:2001] X_test, y_test = bitcoin_scaled[2000:], bitcoin_scaled[2001:]
Simple NN model
nn_model = Sequential() nn_model.add(Dense(224, activation='relu', input_dim=1)) nn_model.add(Dense(224)) nn_model.compile(loss='mse', optimizer='adam')
nn_model.fit(X_train, y_train, epochs=50, batch_size=32) nn_loss, nn_acc = nn_model.evaluate(X_test, y_test)
RNN Model
rnn_model = Sequential() rnn_model.add(RNN(10))
rnn_model.compile(loss='mse', optimizer='adam')rnn_model.fit(X_train, y_train, epochs=50, batch_size=32) rnn_loss, rnn_acc = rnn_model.evaluate(X_test, y_test)
LSTM Model
lstm_model = Sequential() lstm_model.add(LSTM(32, return_sequences=True)) lstm_model.add(LSTM(32))
lstm_model.compile(loss='mse', optimizer='adam')lstm_model.fit(X_train, y_train, epochs=50, batch_size=32) lstm_loss, lstm_acc = lstm_model.evaluate(X_test, y_test)
- Assistant