A quick look at normalizing data

Built by matix.io . Data provided by Canada's Open Data project ( license ). Normalization formulas from Sebastian Raschka's blog

The colors from this week's #CodePenChallenge made me think of shopping 🛍. I jumped off to find some shopping datasets to look into. I was briefly considering a dataset from Kaggle, but was worried about licensing issues. In the end I settled on something from Canada's Open Data project. If you're interested, the dataset and licensing is linked at the bottom. After charting the data, and needing to normalize it, I decided to make that the topic of this pen!

The dataset shows retail trade (sales to consumers) and retail e-commerce sales. Below, you can see the data plotted:

As you can see, retail trade dwarfs e-commerce sales. It's impossible to compare the two sets of datapoints this way. So what can we do? We normalize the data.

How you do it depends on what you want to see. In general, you want to compare each data point in the set to the whole set to get a relative value rather than an absolute value.

We'll look at one common method of normalization: min-max scaling .

For min-max scaling , we'll first find the minimum min and maximum max values in the dataset. Then, for each data point p , we'll plot (p - min) / (max - min)

It's now easier to compare the two sets of data. We can see that e-commerce sales spike drastically around the holidays, whereas retail sales experience a much more modest spike.

That's all for now! ✌️