← capítulo

The simplest classifier

One feature. One line. Everyone above it, sick; below it, healthy.

The dumbest model that could work — and the bar everything else has to clear.

Why start here

The data

768 diabetes patients, eight measurements each. We use one: blood glucose.

The two groups overlap, but the diabetic readings lean high.

The whole model

Predict diabetic when glucose clears a cutoff:

y^i(θ)=1 ⁣[giθ]\hat{y}_i(\theta) = \mathbb{1}\!\left[\, g_i \ge \theta \,\right]

"Training" is one line of search — the cutoff with the highest accuracy:

θ=argmaxθ  1Ni1 ⁣[y^i(θ)=yi]\theta^{*} = \arg\max_{\theta} \; \frac{1}{N}\sum_i \mathbb{1}\!\left[\hat{y}_i(\theta) = y_i\right]

That's it. An argmax over one integer.

Watch the search

Every frame is one real iteration. Red rings are the cutoff's current mistakes; the lower panel traces accuracy as the line moves.

The trade-off you can't escape

Low cutoff: catch every diabetic, flag half the healthy. High cutoff: the reverse. No setting zeroes both mistakes.

Where you put the line is a decision about which mistake you'd rather make.

Scratch vs. library

DecisionTreeClassifier(max_depth=1) is the same model. The bars land on top of each other.

Takeaways