September 2019
Intermediate to advanced
420 pages
10h 29m
English
Finally, we might find ourselves not caring too much about the exact feature values of the data. Instead, we might just want to know whether a feature is present or absent. Binarizing the data can be achieved by thresholding the feature values. Let's quickly remind ourselves of our feature matrix, X:
In [9]: XOut[9]: array([[ 1., -2., 2.], [ 3., 0., 0.], [ 0., 1., -1.]])
Let's assume that these numbers represent the thousands of dollars in our bank accounts. If there are more than 0.5 thousand dollars in the account, we consider the person rich, which we represent with a 1. Otherwise, we put a 0. This is akin to thresholding the data with threshold=0.5:
In [10]: binarizer = preprocessing.Binarizer(threshold=0.5)... X_binarized ...
Read now
Unlock full access