Get your own Python server Result Size: 625 x 565
x
 
import pandas
import scipy
import numpy
from sklearn.preprocessing import Binarizer
fileurl = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
names = ['septal_length','sepal_with','petal_length','pedal_width','class']
data = pandas.read_csv(fileurl, names=names)
array = data.values
# input/output component separation
X = array[:,0:4]
Y = array[:,4]
#treshold is set to 1.4
binarizer = Binarizer(threshold=1.4).fit(X) 
binaryX = binarizer.transform(X)
# summarize transformed data
numpy.set_printoptions(precision=2)
print(binaryX[0:20,:])
#Anything below the threshold is made into a 0.
[[1. 1. 0. 0.]
 [1. 1. 0. 0.]
 [1. 1. 0. 0.]
 [1. 1. 1. 0.]
 [1. 1. 0. 0.]
 [1. 1. 1. 0.]
 [1. 1. 0. 0.]
 [1. 1. 1. 0.]
 [1. 1. 0. 0.]
 [1. 1. 1. 0.]
 [1. 1. 1. 0.]
 [1. 1. 1. 0.]
 [1. 1. 0. 0.]
 [1. 1. 0. 0.]
 [1. 1. 0. 0.]
 [1. 1. 1. 0.]
 [1. 1. 0. 0.]
 [1. 1. 0. 0.]
 [1. 1. 1. 0.]
 [1. 1. 1. 0.]]