We'll start by installing Keras. In order to install Keras, you will need to have Theano or TensorFlow installed in your system. In this example, we'll go with TensorFlow as the backend for Keras.
There are two variants of TensorFlow: a CPU version and a GPU version.
To install the current CPU-only version, use the following command:
pip install tensorflow
If you have to install the GPU package, use the following command:
pip install tensorflow-gpu
Once you've installed TensorFlow, you'll need to install Keras using the following command:
sudo pip install keras
In order to upgrade your already-installed Keras library, use the following command:
sudo pip install --upgrade keras
Once we're done with installing the libraries, let's import the required libraries:
import os
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
from keras.models import Sequential
from keras.layers import Dense
We set our working directory according to our requirements:
os.chdir("..../Chapter 9")
os.getcwd()
We read our energydata.csv dataset:
df_energydata = pd.read_csv("energydata.csv")
We check whether there are any null values in our dataset:
df_energydata.isnull().sum()