- 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 Estimator to make predictions from trained model?

Tensorflow can be used with the estimator to predict output on new data using the ‘predict’ method which is present in the ‘classifier’ method.

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

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.

The model is trained using iris data set. There are 4 features, and one label.

- sepal length
- sepal width
- petal length
- petal width

## Example

print(“Generating predictions from model”) expected = ['Setosa', 'Versicolor', 'Virginica'] predict_x = { 'SepalLength': [5.1, 5.9, 6.9], 'SepalWidth': [3.3, 3.0, 3.1], 'PetalLength': [1.7, 4.2, 5.4], 'PetalWidth': [0.5, 1.5, 2.1], } print(“Defining input function for prediction”) print(“It converts inputs to dataset without labels”) def input_fn(features, batch_size=256): return tf.data.Dataset.from_tensor_slices(dict(features)).batch(batch_size) predictions = classifier.predict( input_fn=lambda: input_fn(predict_x))

Code credit −https://www.tensorflow.org/tutorials/estimator/premade#first_things_first

## Output

Generating predictions from model Defining input function for prediction It converts inputs to dataset without labels

## Explanation

- The model that is trained would produce good results.
- This can be usd to predict species of an Iris flower, based on certain unlabelled measurements.
- The predictions are made using a single function call.

- Related Articles
- How can Tensorflow and pre-trained model be used to create base model from pre-trained convnets?
- How can Tensorflow be used with Estimator to compile the model using Python?
- How can Tensorflow be used with pre-trained model to rescale pixel values?
- How can Tensorflow used with the pre-trained model to compile the model?
- How can Tensorflow and Estimator be used with Boosted trees to train and evaluate the model?
- How can Tensorflow and pre-trained model be used to compile the model using Python?
- How can Tensorflow and re-trained model be used for data augmentation?
- How can Tensorflow and pre-trained model be used for feature extraction?
- How can Tensorflow and pre-trained model be used for fine tuning?
- How can Tensorflow and pre-trained model be used to add classification head to the model?
- How can Tensorflow be used with pre-trained model to build the training and validation dataset?
- How can Tensorflow and pre-trained model be used to continue training the model using Python?
- How can Tensorflow and pre-trained model be used to convert images from one dimension to another?
- How can Tensorflow and pre-trained model be used to understand the learning curve?
- How can Tensorflow be used with Estimator to transform the feature column?