Scikit-Learn
9
Preprocessing the Data
As we are dealing with lots of data and that data is in raw form, before inputting that data
to machine learning algorithms, we need to convert it into meaningful data. This process
is called
preprocessing the data. Scikit-learn has package named
preprocessing
for this
purpose. The
preprocessing
package has the following techniques:
Binarisation
This preprocessing technique is used when we need to convert our numerical values into
Boolean values.
Example
import
numpy as np
from sklearn import preprocessing
Input_data = np.array([2.1, -1.9, 5.5],
[-1.5, 2.4, 3.5],
[0.5, -7.9, 5.6],
[5.9, 2.3, -5.8]])
data_binarized = preprocessing.Binarizer(threshold=0.5).transform(input_data)
print("\nBinarized data:\n", data_binarized)
In the above example, we used
threshold value =
Dostları ilə paylaş: