Explain with an example how to do feature preprocessing using keras?

This recipe explains with an example how to do feature preprocessing using keras

Recipe Objective

With an example, elaborate how to do feature preprocessing using keras

The Keras preprocessing layers API gives an option to developers to build Keras-native input processing pipelines. These pipelines can be used as independent preprocessing code in non-Keras workflows, they can be combined directly with Keras models.

Learn to Build a Multi Class Image Classification Model in Python from Scratch

Step 1- Importing Library

import numpy as np import tensorflow as tf from tensorflow.keras.layers.experimental import preprocessing

Step 2- Creating a 2d array.

Preprocessing a 2D array.

X = np.array([[4,8,10], [40,100, 120], [200, 300, 1000],[1000,5000,10000]]) layer = preprocessing.Normalization() layer.adapt(data) normalized_X = layer(X)

Step 3- Printing the mean and Standard Deviation of Data.

print("Features mean: %.2f" % (normalized_X.numpy().mean())) print("Features std: %.2f" % (normalized_X.numpy().std()))

What Users are saying..

profile image

Ray han

Tech Leader | Stanford / Yale University
linkedin profile url

I think that they are fantastic. I attended Yale and Stanford and have worked at Honeywell,Oracle, and Arthur Andersen(Accenture) in the US. I have taken Big Data and Hadoop,NoSQL, Spark, Hadoop... Read More

Relevant Projects

NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

Learn Object Tracking (SOT, MOT) using OpenCV and Python
Get Started with Object Tracking using OpenCV and Python - Learn to implement Multiple Instance Learning Tracker (MIL) algorithm, Generic Object Tracking Using Regression Networks Tracker (GOTURN) algorithm, Kernelized Correlation Filters Tracker (KCF) algorithm, Tracking, Learning, Detection Tracker (TLD) algorithm for single and multiple object tracking from various video clips.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Isolation Forest Model and LOF for Anomaly Detection in Python
Credit Card Fraud Detection Project - Build an Isolation Forest Model and Local Outlier Factor (LOF) in Python to identify fraudulent credit card transactions.

Detectron2 Object Detection and Segmentation Example Python
Object Detection using Detectron2 - Build a Dectectron2 model to detect the zones and inhibitions in antibiogram images.

Create Your First Chatbot with RASA NLU Model and Python
Learn the basic aspects of chatbot development and open source conversational AI RASA to create a simple AI powered chatbot on your own.

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

PyTorch Project to Build a GAN Model on MNIST Dataset
In this deep learning project, you will learn how to build a GAN Model on MNIST Dataset for generating new images of handwritten digits.

Build a Multi-Class Classification Model in Python on Saturn Cloud
In this machine learning classification project, you will build a multi-class classification model in Python on Saturn Cloud to predict the license status of a business.

Time Series Python Project using Greykite and Neural Prophet
In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.