Deciphering Market Trends: An Exploration of LSTM and GRU in Predicting Google’s Stock Prices
Import Libraries
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import plotly.express as px
from keras.preprocessing.sequence import TimeseriesGenerator
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense,LSTM, Dropout , GRU
from tensorflow.keras.callbacks import EarlyStopping
import warnings
from warnings import filterwarnings
warnings.simplefilter(action='ignore')
%matplotlib inline
First we need to import the necessary libraries, which sets up the tools for preprocessing and splitting data, and creates a model for predicting data using LSTM and GRU layers.
Import Data
Data = pd.read_csv('../input/google-stock-prediction/GOOG.csv',parse_dates=True)
Here we read a CSV file, into a variable called Data. Then it parses the data into a readable format and stores it.