<jupyter_start><jupyter_text>Data Preprocessing  Feature Scaling<jupyter_code>from sklearn.preprocessing import MinMaxScaler
sc = MinMaxScaler(feature_range = (0,1))
train_scaled = sc.fit_transform(train)
x_train = []
y_train = []
for i in range(60,1258):
    x_train.append(train_scaled[i-60:i,0])
    y_train.append(train_scaled[i,0])
x_train = np.array(x_train)
y_train = np.array(y_train)
x_train = np.reshape(x_train,(x_train.shape[0],x_train.shape[1],1))<jupyter_output><empty_output><jupyter_text>Building the RNN<jupyter_code>from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from keras.layers import Dropout
regressor = Sequential()
#First LSTM Layer
regressor.add(LSTM(units=50, return_sequences = True, input_shape = (x_train.shape[1],1)))
regressor.add(Dropout(0.2))

#Second LSTM Layer
regressor.add(LSTM(units=50, return_sequences = True))
regressor.add(Dropout(0.2))

#Third LSTM Layer
regressor.add(LSTM(units=50, return_sequences = True))
regressor.add(Dropout(0.2))

#Fourth LSTM Layer
regressor.add(LSTM(units=50))
regressor.add(Dropout(0.2))

#Output Layer
regressor.add(Dense(units=1))
regressor.compile(optimizer = 'adam', loss = 'mean_squared_error')
regressor.fit(x_train,y_train,epochs=100,batch_size=32)<jupyter_output>Epoch 1/100
38/38 [==============================] - 31s 114ms/step - loss: 0.0738
Epoch 2/100
38/38 [==============================] - 5s 134ms/step - loss: 0.0074
Epoch 3/100
38/38 [==============================] - 5s 134ms/step - loss: 0.0055
Epoch 4/100
38/38 [==============================] - 5s 134ms/step - loss: 0.0056
Epoch 5/100
38/38 [==============================] - 5s 134ms/step - loss: 0.0046
Epoch 6/100
38/38 [==============================] - 5s 134ms/step - loss: 0.0050
Epoch 7/100
38/38 [==============================] - 5s 134ms/step - loss: 0.0053
Epoch 8/100
38/38 [==============================] - 5s 133ms/step - loss: 0.0050
Epoch 9/100
38/38 [==============================] - 5s 133ms/step - loss: 0.0060
Epoch 10/100
38/38 [==============================] - 5s 135ms/step - loss: 0.0042
Epoch 11/100
38/38 [==============================] - 6s 154ms/step - loss: 0.0040
Epoch 12/100
38/38 [==============================] - 5s 136ms/step - loss: 0.0037
Epoch 13/100[...]<jupyter_text>Now, making predictions using the test dataset<jupyter_code>stock_test = pd.read_csv('Google_Stock_Price_Test.csv',index_col = "Date", parse_dates = True)
actual_stock = stock_test.iloc[:,1:2].values
stock_test.head()
stock_test.info()
stock_test['Volume'] = stock_test['Volume'].str.replace(',','').astype(float)
test = pd.DataFrame(stock_test['Open'])
stock_total = pd.concat((stock['Open'],stock_test['Open']), axis = 0)
inputs = stock_total[len(stock_total) - len(stock_test) - 60:].values
inputs = inputs.reshape(-1,1)
inputs = sc.transform(inputs)
x_test = []
for i in range(60,80):
    x_test.append(inputs[i-60:i,0])
x_test = np.array(x_test)
x_test = np.reshape(x_test,(x_test.shape[0],x_test.shape[1],1))
stock_prediction = regressor.predict(x_test)
stock_prediction = sc.inverse_transform(stock_prediction)
stock_prediction = pd.DataFrame(stock_prediction)<jupyter_output><empty_output><jupyter_text>Visualizing the Results<jupyter_code>plt.figure(figsize = (12,6))
plt.title("Google Stock Price Prediction")
plt.xlabel("Time")
plt.ylabel("Google Stock Price")
plt.plot(actual_stock, color = 'blue',label = 'Actual Google Stock Price')
plt.plot(stock_prediction,color = 'red', label = 'Predicted Google Stock Price')
plt.legend()
plt.plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23802895322939865, 'fraction_numerical': 0.0757238307349666, 'mean_word_length': 6.580168776371308, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '261891', 'license': 'MIT', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1292, 'n_words': 239, 'path': 'Stock Market Prediction.ipynb', 'repo_name': 'AaryanMadan54/Stock-Market-Prediction', 'size': '3592'}