How to do it...

In this recipe, we will use a pre-made dnn_regressor estimator. Let's get started and build and train a deep learning estimator model:

  1. We need to execute some steps before building an estimator neural network. First, we need to create a vector of feature names:
features_set <- setdiff(names(dummy_data_estimator), "target")

Here, we construct the feature columns according to the Estimator API. The feature_columns() function is a constructor for feature columns, which defines the expected shape of the input to the model:

feature_cols <- feature_columns( column_numeric(features_set))
  1. Next, we define an input function so that we can select feature and response variables:
estimator_input_fn <- function(data_,num_epochs = 1) ...

Get Deep Learning with R Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.