How to do it...

TensorFlow has included some default model estimator functions that we will rely on for this recipe. There are two main gradient-boosted models, a regression-tree and a classification-tree. For this example, we will be using a regression tree to predict the boston house price dataset (https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html).

  1. To start we load the necessary libraries:
import numpy as npimport tensorflow as tffrom keras.datasets import boston_housingfrom tensorflow.python.framework import opsops.reset_default_graph()
  1. Next, we set the model we are going to use from the TensorFlow estimator library. Here, we will use the BoostedTreesRegressor model, which is used for regression with gradient boosted ...

Get TensorFlow Machine Learning Cookbook - Second Edition 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.