- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 Tensorflow is used with Estimators to build a linear model to load the titanic dataset?
A linear model can be built with estimators to load the titanic dataset using the ‘read_csv’ method which is present in ‘Pandas’ package. This method takes google APIs that store the titanic dataset. The API is read and the data is stored in the form of a CSV file.
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.
TensorFlow Text contains collection of text related classes and ops that can be used with TensorFlow 2.0. The TensorFlow Text can be used to preprocess sequence modelling.
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.
pip install -q sklearn
import os import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt from IPython.display import clear_output from six.moves import urllib import tensorflow.compat.v2.feature_column as fc import tensorflow as tf 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("Removing feature 'survived'") y_train = dftrain.pop('survived') y_eval = dfeval.pop('survived')
Load the dataset Removing feature 'survived'
- The required packages are downloaded.
- The data is downloaded from the API.
- The column ‘survived’ is deleted.
- 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 be used with Estimators to inspect the titanic dataset using Python?
- 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 abalone dataset to build a sequential model?
- 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 optimize the model?
- How can Tensorflow be used with Estimators to split the iris dataset?
- How can Tensorflow be used with pre-trained model to build the training and validation dataset?
- How can Tensorflow be used with Estimators to display metadata about the dataset?
- How can Tensorflow be used to train and evaluate the titanic dataset?
- How can TensorFlow be used to build the model for Fashion MNIST dataset in Python?
- How can Tensorflow be used with Estimators to evaluate the model using Python?