NumPy Exercise

Contents

2.2. NumPy Exercise#

2.2.1. Task#

In machine learning tasks, when we deal with data from different features, it is very common that we need to normalize data so that the different units among features would not affect the performances of machine learning algorithms.

Now we have temperature and precipitation observations from 7 sites. Write a line of code to accomplish Min-Max normalization for each feature.

Hint: The equation of Min-Max normalization to \(x\) is \( \begin{align} x_{norm} = \frac{x-\min(x)}{\max(x)-\min(x)} \end{align} \)

import numpy as np
data = np.array([[25.1, 27.5, 32.3, 24.4, 28.2, 29.8, 30.1],  # a row of temperature
                 [20.0,  2.5,  8.5, 10.0,  0.5, 28.4, 12.5]]) # a row of precipitation

# Your solution goes here.