Write train(examples) where each example is (feature, label). Learn the threshold as the midpoint between the mean feature of the label-1 examples and the mean feature of the label-0 examples, and return it.
Write train(examples) where each example is (feature, label). Learn the threshold as the midpoint between the mean feature of the label-1 examples and the mean feature of the label-0 examples, and return it.