How can Tensorflow be used with Estimators to inspect a specific column of titanic dataset?

TensorflowServer Side ProgrammingProgramming

A specific column in the titanic dataset can be inspected by accessing the column-to-be-inspected and using the ‘DenseFeatures’ and converting it into a Numpy array.

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. 

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.

Example

print("Results of a specific column are being inspected")
age_column = feature_columns[7]
tf.keras.layers.DenseFeatures([age_column])(feature_batch).numpy()

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

Output

Results of a specific column are being inspected
array([[61. ],
   [17. ],
   [19. ],
   [55.5],
   [26. ],
   [20. ],
   [24. ],
   [ 9. ],
   [31. ],
  [28. ]], dtype=float32)

Explanation

  • The result of a specific feature column is inspected.
  • This is done with the help of the tf.keras.layers.DenseFeatures layer.
raja
Published on 12-Feb-2021 12:16:42
Advertisements