this is our first modeland it works very well in that it separates the iris setosa flowers from the other two species without making any mistakes what we had here was simple structurea simple threshold on one of the dimensions then we searched for the best dimension threshold we performed this visually and with some calculationmachine learning happens when we write code to perform this for us the example where we distinguished iris setosa from the other two species was very easy howeverwe cannot immediately see what the best threshold is for distinguishing iris virginica from iris versicolor we can even see that we will never achieve perfect separation we canhowevertry to do it the best possible way for thiswe will perform little computation we first select only the non-setosa features and labelsfeatures features[~is_setosalabels labels[~is_setosavirginica (labels ='virginica'here we are heavily using numpy operations on the arrays is_setosa is boolean arrayand we use it to select subset of the other two arraysfeatures and labels finallywe build new boolean arrayvirginicausing an equality comparison on labels nowwe run loop over all possible features and thresholds to see which one results in better accuracy accuracy is simply the fraction of examples that the model classifies correctlybest_acc - for fi in xrange(features shape[ ])we are going to generate all possible threshold for this feature thresh features[:,ficopy(thresh sort(now test all thresholdsfor in threshpred (features[:,fitacc (pred =virginicamean(if acc best_accbest_acc acc best_fi fi best_t