<jupyter_start><jupyter_text>**GRU**<jupyter_code># define model1 GRU
sg_time = time.time()
model1 = Sequential()
model1.add(GRU(100, activation='linear', return_sequences=True, input_shape=(3, 1)))
model1.add(GRU(50, activation='linear'))
model1.add(Dense(1))
model1.compile(optimizer='adam', loss='mse')
# fit model
model1.fit(X_train, y_train, epochs=100, verbose=1)
eg_time = time.time()
print("Execution Time: ",eg_time-sg_time)
### Lets Do the prediction and check performance metrics
train_predict=model1.predict(X_train)
test_predict=model1.predict(X_test)
### Calculate MSE performance metrics
import math
from sklearn.metrics import mean_squared_error
mean_squared_error(y_train,train_predict)

### Calculate MSE performance metrics
import math
from sklearn.metrics import mean_squared_error
mse1 = mean_squared_error(y_test,test_predict)
mse1
### Calculate r2 performance metrics
import math
from sklearn.metrics import r2_score
r1 = r2_score(y_test,test_predict)
r1<jupyter_output><empty_output><jupyter_text>**LSTM**<jupyter_code># define model2 LSTM
sl_time = time.time()
model2 = Sequential()
model2.add(LSTM(100, activation='linear', return_sequences=True, input_shape=(3, 1)))
model2.add(LSTM(50, activation='linear'))
model2.add(Dense(1))
model2.compile(optimizer='adam', loss='mse')
# fit model
model2.fit(X_train, y_train, epochs=100, verbose=1)
el_time = time.time()
print("Execution time: ", el_time-sl_time)
### Lets Do the prediction and check performance metrics
train_predict=model2.predict(X_train)
test_predict=model2.predict(X_test)
### Calculate MSE performance metrics
import math
from sklearn.metrics import mean_squared_error
mean_squared_error(y_train,train_predict)
### Calculate MSE performance metrics
import math
from sklearn.metrics import mean_squared_error
mse2 = mean_squared_error(y_test,test_predict)
mse2
### Calculate r2 performance metrics
import math
from sklearn.metrics import r2_score
r2 = r2_score(y_test,test_predict)
r2
# plot 
plt.plot(scaler.inverse_transform(y_test))
plt.plot(scaler.inverse_transform(test_predict))
plt.xlim(200,300)
plt.show()
df_model = pd.DataFrame({'Model_Applied': ['GRU', 'LSTM'], 'MSE': [mse1, mse2], 'R2': [r1, r2],
                         'Execution Time': [eg_time - sg_time, el_time - sl_time]})
df_model<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12451529513140888, 'fraction_numerical': 0.02886686772942697, 'mean_word_length': 7.930769230769231, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '492943', 'license': 'Apache-2.0', 'n_tokens_mistral': 863, 'n_tokens_neox': 807, 'n_words': 173, 'path': 'prediction/Deep_Learning_Models.ipynb', 'repo_name': 'sainiprathmesh/Bitcoin_Price_Alert_and_Prediction_System', 'size': '2321'}