for exampleif we choose threshold value then the dataset value above it will become and below this will become that is why we can call it binarizing the data or thresholding the data this technique is useful when we have probabilities in our dataset and want to convert them into crisp values we can binarize the data with the help of binarizer class of scikit-learn python library example in this examplewe will rescale the data of pima indians diabetes dataset which we used earlier firstthe csv data will be loaded and then with the help of binarizer class it will be converted into binary values and depending upon the threshold value we are taking as threshold value the first few lines of following script are same as we have written in previous while loading csv data from pandas import read_csv from sklearn preprocessing import binarizer path ' :\pima-indians-diabetes csvnames ['preg''plas''pres''skin''test''mass''pedi''age''class'dataframe read_csv(pathnames=namesarray dataframe values nowwe can use binarize class to convert the data into binary values binarizer binarizer(threshold= fit(arraydata_binarized binarizer transform(arrayherewe are showing the first rows in the output print ("\nbinary data:\ "data_binarized [ : ]output binary data[[ [ [ [ [ ]