Getting ready

The Boston Housing Prices dataset can be accessed directly from the keras library. It has 404 training examples and 102 test examples.

Let's load the required libraries:

library(mxnet)
library(keras)

We load the dataset and split it into training and testing sets:

boston = dataset_boston_housing()
train_x = boston$train$x
train_y = boston$train$y
test_x = boston$test$x
test_y = boston$test$y

Let's now scale the dataset:

# normalize train set
train_x <- scale(train_x)

# normalize test set
train_means <- attr(train_x, "scaled:center")
train_stddevs <- attr(train_x, "scaled:scale")
test_x <- scale(test_x, center = train_means, scale = train_stddevs)

This completes the data preprocessing part.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset