- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can Tensorflow be used with boosted trees in Python?
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.
Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?
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.
import numpy as np import pandas as pd from IPython.display import clear_output from matplotlib import pyplot as plt print("Load the dataset") dftrain = pd.read_csv('https://storage.googleapis.com/tf-datasets/titanic/train.csv') dfeval = pd.read_csv('https://storage.googleapis.com/tf-datasets/titanic/eval.csv') print("Delete the column 'survived'") y_train = dftrain.pop('survived') y_eval = dfeval.pop('survived') import tensorflow as tf tf.random.set_seed(123)
Code credit −https://www.tensorflow.org/tutorials/estimator/boosted_trees
Load the dataset Delete the column 'survived'
- The required packgaes are imported.
- The dataset is loaded.
- It is read as a csv file.
- The column ‘survived’ is deleted.
- Related Articles
- How can Tensorflow and Estimator be used with Boosted trees to train and evaluate the model?
- How can Tensorflow be used with Estimator to show a sample of the data using boosted trees?
- How can Tensorflow text be used with whitespace tokenizer in Python?
- How can Tensorflow be used to work with character substring in Python?
- How can Tensorflow be used with tf.data for finer control using Python?
- How can Tensorflow be used with Estimator to compile the model using Python?
- How can Tensorflow be used with Estimators to evaluate the model using Python?
- How can Tensorflow be used with Estimator to predict the output using Python?
- How can Tensorflow be used to define feature columns in Python?
- How can Tensorflow be used to compose layers using Python?
- How can Tensorflow be used with Estimators to inspect the titanic dataset using Python?
- How can Tensorflow be used to prepare the dataset with stackoverflow questions using Python?
- How can TensorFlow be used to preprocess Fashion MNIST data in Python?
- How can Tensorflow be used to visualize the data using Python?
- How can Tensorflow be used to standardize the data using Python?