How Tensorflow be used to determine data about class to which every passenger in the titanic dataset belongs to?


Tensorflow can be used with Estimators to determine data about the class to which every passenger in the titanic dataset belongs to, with the help of the ‘value_counts’ method. This data is visualized as a horizontal bar graph.

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. 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.

Example

print("Data about class to which each passenger belong")
dftrain['class'].value_counts().plot(kind='barh')
plt.show()
print("Data about passengers who start their journey from a specific location")
dftrain['embark_town'].value_counts().plot(kind='barh')
plt.show()

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

Output

Explanation

  • More information about which class each passenger belongs to is obtained.

  • This information is plotted on the graph to understand more about the data.

Updated on: 25-Feb-2021

23 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements