-
class
sklearn.preprocessing.
Binarizer
(threshold=0.0, copy=True)
超過設為 1
其餘設為 0
output:
import pandas as pd
import numpy as np
from sklearn import preprocessing
from sklearn.preprocessing import Binarizer
data = [[1,2,3]
,[9,5,4]
,[7,6,8]
,[12,8,9]]
binarizer = Binarizer(threshold=8)
# if > threshold number= 1 else number = 0
print("Binarizer data : \n" ,binarizer.fit_transform(data))
Binarizer data :
[[0 0 0]
[1 0 0]
[0 0 0]
[1 0 1]]
github code
沒有留言:
張貼留言