Performing logistic regression using TensorFlow
In this section, we will cover the application of TensorFlow in setting up a logistic regression model. The example will use a similar dataset to that used in the H2O model setup.
Getting ready
The previous chapter provided details for the installation of TensorFlow. The code for this section is created on Linux but can be run on any operating system. To start modeling, load the tensorflow
package in the environment. R loads the default TensorFlow environment variable and also the NumPy library from Python in the np
variable:
library("tensorflow") # Load TensorFlow np <- import("numpy") # Load numpy library
How to do it...
The data is imported using a standard function from R, as shown in the following code.
- The data is imported using the
read.csv
file and transformed into the matrix format followed by selecting the features used to model as defined inxFeatures
andyFeatures
. The next step in TensorFlow is to set up a graph to run optimization...