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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.