# How can Tensorflow be used with boosted trees in Python?

TensorflowPythonServer Side ProgrammingProgramming

Tensorflow can be used with boosted trees to improve the prediction performance of the dataset. The data is loaded, and pre-processed in the way it is usually done, but when the predictions are made, multiple models are used for the predictions, and the output of all these models is combined to give the final result.

We will use the Keras Sequential API, which is helpful in building a sequential model that is used to work with a plain stack of layers, where every layer has exactly one input tensor and one output tensor.

A neural network that contains at least one layer is known as a convolutional layer. We can use the Convolutional Neural Network to build learning model.

We are using the Google Colaboratory to run the below code. Google Colab or Colaboratory helps run Python code over the browser and requires zero configuration and free access to GPUs (Graphical Processing Units). Colaboratory has been built on top of Jupyter Notebook.

We will see how a gradient boosting model can be trained using decision trees and tf.estimator API. Boosted Trees models are considered the most popular and effective machine learning approaches for regression as well as classification. It is an ensemble technique which combines the predictions from many (10s or 100s or 1000s) tree models. They help achieve impressive performance along with minimal hyperparameter tuning.

## Example

import numpy as np
import pandas as pd
from IPython.display import clear_output
from matplotlib import pyplot as plt
print("Delete the column 'survived'")
y_train = dftrain.pop('survived')
y_eval = dfeval.pop('survived')
import tensorflow as tf
tf.random.set_seed(123)

## Output

Load the dataset
Delete the column 'survived'

## Explanation

• The required packgaes are imported.