- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- 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 Estimators to train the model for titanic dataset?

The titanic dataset can be trained by creating a model using the ‘LinearClassifier’, and training it using the ‘train’ method. The train method is present in the ‘estimator’ class of tensorflow library.

**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 will train a logistic regression model using the tf.estimator API. The model is used as a baseline for other algorithms. We use the titanic dataset with the goal of predicting passenger survival, given characteristics such as gender, age, class, etc. Estimators use feature columns to describe how the model would interpret the raw input features. An Estimator expects a vector of numeric inputs, and feature columns will help describe how the model should convert every feature in the dataset.

print("The base features are added") print("The model is trained") linear_est = tf.estimator.LinearClassifier(feature_columns=feature_columns) linear_est.train(train_input_fn) result = linear_est.evaluate(eval_input_fn) clear_output() print(result)

Code credit −https://www.tensorflow.org/tutorials/estimator/linear

## Output

The base features are added The model is trained {'accuracy': 0.7613636, 'accuracy_baseline': 0.625, 'auc': 0.809244, 'auc_precision_recall': 0.75609726, 'average_loss': 0.5452906, 'label/mean': 0.375, 'loss': 0.5347039, 'precision': 0.75, 'prediction/mean': 0.27201703, 'recall': 0.54545456, 'global_step': 200}

## Explanation

- Once the base features are all added to the model, the mode is trained.
- This is done using a single command with the help of tf.estimator API.

- Related Questions & Answers
- How can Tensorflow be used to train and evaluate the titanic dataset?
- How can Tensorflow be used with Estimators to inspect the titanic dataset using Python?
- How can Tensorflow be used with Estimators to add a column to the titanic dataset?
- How can Tensorflow be used with Estimators to inspect a specific column of titanic dataset?
- How can Tensorflow and Estimators be used to predict the output of the titanic dataset?
- How can Tensorflow be used with Estimators to explore the titanic data?
- How can Tensorflow be used with estimators to visualize the titanic data?
- How can TensorFlow be used to train the model for Fashion MNIST dataset in Python?
- How Tensorflow is used with Estimators to build a linear model to load the titanic dataset?
- How can Tensorflow be used with Estimators for feature engineering the model?
- How can Tensorflow be used with Estimators to optimize the model?
- How can Tensorflow be used with Estimators to split the iris dataset?
- How can Tensorflow be used to train the model with the stackoverflow question dataset using Python?
- How can Tensorflow be used with Estimators to display metadata about the dataset?
- How can Tensorflow be used to train the model using Python?