- 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 transform the feature column?

Tensorflow can be used with Estimator to transform the feature column by first converting the first row of the dataset into a dictionary, and then uses one-hot encoding to transform this feature column, i.e. the ‘gender’ column.

**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. 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("An example transformation produced by a feature column") example = dict(dftrain.head(1)) class_fc = tf.feature_column.indicator_column(tf.feature_column.categorical_column_with_vocabulary_list('class', ('First', 'Second', 'Third'))) print('Feature value is: "{}"'.format(example['class'].iloc[0])) print('One-hot encoded is: ', tf.keras.layers.DenseFeatures([class_fc])(example).numpy())

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

## Output

An example transformation produced by a feature column Feature value is: "Third" One-hot encoded is: [[0. 0. 1.]]

## Explanation

The transformation produced by a feature column can be seen.

The output of indicator_column on a single example can be viewed on the console.

- Related Articles
- How can Tensorflow and Estimator be used to view all feature column transformations at once?
- How can Tensorflow be used with premade estimator to download the Iris dataset?
- How can Tensorflow be used with Estimator to compile the model using Python?
- How can Tensorflow be used with Estimator to predict the output using Python?
- How can Tensorflow be used with Estimator to make predictions from trained model?
- How can Tensorflow be used to instantiate an estimator using Python?
- How can Tensorflow be used with Estimators for feature engineering the model?
- How can Tensorflow and Estimator be used with Boosted trees to train and evaluate the model?
- How can Tensorflow be used to define feature columns in Python?
- How Tensorflow be used for the gender column, like feature column helping in prediction?
- How can Tensorflow be used with Estimators to create feature columns and input functions?
- How can Tensorflow be used with Estimator to show a sample of the data using boosted trees?
- How can Tensorflow be used to create a feature extractor using Python?
- How can Tensorflow and Estimator be used to find the ROC curve on titanic dataset?
- How can Tensorflow and pre-trained model be used for feature extraction?