9. Recurrent Neural Networks
Activity 9.01: Building an RNN with Multiple LSTM Layers to Predict Power Consumption
Solution:
Perform the following steps to complete this activity.
- Open a new Jupyter or Colab notebook.
- Import the libraries needed. Use
numpy
,pandas
,datetime
, andMinMaxScaler
to scale the dataset between zero and one:import numpy as np import pandas as pd import datetime from sklearn.preprocessing import MinMaxScaler
- Use the
read_csv()
function to read in your CSV file and store your dataset in a pandas DataFrame,data
:data = pd.read_csv("household_power_consumption.csv")
- Create a new column,
Datetime
, by combiningDate
andTime
columns using the following code:data['Date'] = pd.to_datetime(data['Date'], format="%d/%m/%Y") data['Datetime'] = data['Date'].dt.strftime('%Y-%m-%d') + ' ' \ ...