in Machine Learning by
Q:

What is Binarizing of data? How to Binarize?

1 Answer

0 votes
by
In most of the Machine Learning Interviews, apart from theoretical questions, interviewers focus on the implementation part. So, this ML Interview Questions in focused on the implementation of the theoretical concepts.

Converting data into binary values on the basis of threshold values is known as the binarizing of data. The values that are less than the threshold are set to 0 and the values that are greater than the threshold are set to 1. This process is useful when we have to perform feature engineering, and we can also use it for adding unique features.

We can binarize data using Scikit-learn. The code for binarizing the data using Binarizer is as follows:

from sklearn.preprocessing import Binarizer

import pandas

import numpy

names = ['Abhi', 'Piyush', 'Pranay', 'Sourav', 'Sid', 'Mike', 'pedi', 'Jack', 'Tim']

dataframe = pandas.read_csv(url, names=names)

array = dataframe.values

# Splitting the array into input and output

X = array[:,0:8]

Y = array[:,8]

binarizer = Binarizer(threshold=0.0).fit(X)

binaryX = binarizer.transform(X)

# Summarizing the modified data

numpy.set_printoptions(precision=3)

print(binaryX[0:5,:])
Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

+2 votes
asked May 14, 2019 in Machine Learning by Derya
0 votes
asked Nov 29, 2019 in Machine Learning by SakshiSharma
0 votes
asked Nov 29, 2019 in Machine Learning by SakshiSharma
0 votes
asked Nov 29, 2019 in Machine Learning by SakshiSharma
0 votes
asked Nov 29, 2019 in Machine Learning by SakshiSharma
...