- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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 Estimators to inspect the titanic dataset using Python?
The titanic dataset can be inspected using Tensorflow and estimators, by iterating through the features and converting the features into a list, and displaying it on the console.
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.
An Estimator is TensorFlow's high-level representation of a complete model. It is designed for easy scaling and asynchronous training.
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. Selecting and using the right set of feature columns is essential to learning an effective model.
Example
print("The dataset is being inspected") ds = make_input_fn(dftrain, y_train, batch_size=10)() for feature_batch, label_batch in ds.take(1): print('Some feature keys are:', list(feature_batch.keys())) print() print('A batch of class:', feature_batch['class'].numpy()) print() print('A batch of Labels:', label_batch.numpy())
Code credit −https://www.tensorflow.org/tutorials/estimator/linear
Output
The dataset is being inspected Some feature keys are: ['sex', 'age', 'n_siblings_spouses', 'parch', 'fare', 'class', 'deck', 'embark_town', 'alone'] A batch of class: [b'First' b'First' b'First' b'Third' b'Third' b'Third' b'First' b'Third' b'Second' b'Third'] A batch of Labels: [0 1 1 0 0 0 1 0 0 0]
Explanation
- The dataset is inspected.
- The feature keys, the labels, and the classes are displayed on the console.
- It is done by iterating over a batch of dataset.
- Related Articles
- How can Tensorflow be used with Estimators to inspect a specific column of titanic dataset?
- How can Tensorflow be used with Estimators to train the model for titanic dataset?
- How can Tensorflow be used with Estimators to add a column to the 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 with Estimators to split the iris dataset?
- How can Tensorflow be used with Estimators to display metadata about the dataset?
- How Tensorflow is used with Estimators to build a linear model to load the titanic dataset?
- How can Tensorflow be used to train and evaluate the titanic dataset?
- How can Tensorflow be used with Estimators to evaluate the model using Python?
- How can Tensorflow and Estimator be used to find the ROC curve on titanic dataset?
- How can Tensorflow be used to prepare the dataset with stackoverflow questions using Python?
- How can Tensorflow be used to load the Illiad dataset using Python?
- How can Tensorflow be used to train the Illiad dataset using Python?
