July 2017
Intermediate to advanced
382 pages
9h 13m
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 if 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. Else 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