# Load libraries
from sklearn.preprocessing import Normalizer
import numpy as np

"""
Explanation: 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
<a alt="Normalizing Observations" href="https://machinelearningflashcards.com">
    <img src="normalizing_observations/Normalizing_Observations_print.png" class="flashcard center-block">
</a>
Preliminaries
End of explanation
"""


# 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]])

"""
Explanation: Create Feature Matrix
End of explanation
"""


# Create normalizer
normalizer = Normalizer(norm='l2')

# Transform feature matrix
normalizer.transform(X)

"""
Explanation: Normalize Observations
Normalizer rescales the values on individual observations to have unit norm (the sum of their lengths is one).
End of explanation
"""


