Title: Normalizing Observations
Slug: normalizing_observations
Summary: How to normalize observations for machine learning in Python.
Date: 2016-09-06 12:00
Category: Machine Learning
Tags: Preprocessing Structured Data
Authors: Chris Albon
In [4]:
    
# Load libraries
from sklearn.preprocessing import Normalizer
import numpy as np
    
In [5]:
    
# Create feature matrix
X = np.array([[0.5, 0.5], 
              [1.1, 3.4], 
              [1.5, 20.2], 
              [1.63, 34.4], 
              [10.9, 3.3]])
    
In [6]:
    
# Create normalizer
normalizer = Normalizer(norm='l2')
# Transform feature matrix
normalizer.transform(X)
    
    Out[6]: