Errors in the Training Classifier

Learn to calculate an error in the training classifier and the relationship between our parameter A and the error E.

We'll cover the following

Calculate an error

Let’s look at the first training example: the width is 3.03.0 and the length is 1.01.0 for a ladybug. If we tested the y=Axy = Ax function with this example, where xx is 3.03.0, we would get:

y=(0.25)×(3.0)=0.75y = (0.25) \times (3.0) = 0.75

The function with the parameter AA, which is set to the randomly chosen value of 0.250.25, is suggesting that for a bug of width 3.03.0, the length should be 0.750.75. We know that’s too small because the training data example tells us it must be a length of 1.01.0. So, we have a difference, which indicates an error. Like before, with the miles to kilometers predictor, we can use this error to inform how we adjust the parameter AA.

But before we do that, let’s think about what yy should be again. If yy is 1.01.0, then the line goes right through the point where the ladybug sits at (x,y)=(3.0,1.0)(x,y) = (3.0, 1.0). It’s a subtle distinction, but we don’t actually want that. We want the line to go above that point. Why? Because we want all the ladybug points to be below the line, not on it. The line needs to be a divider between ladybugs and caterpillars, not a predictor of a bug’s length given its width.

So, let’s try to aim for y=1.1y = 1.1 when x=3.0x = 3.0. It’s just incrementally above 1.01.0. We could’ve chosen 1.21.2 or even 1.31.3, but we don’t want a larger number like 1010 or 100100 because that would make it more likely that the line will go above both the ladybugs and caterpillars data points, resulting in a separator that isn’t useful at all. So the desired target is 1.11.1, and the error EE is:

Error = (desired target  actual output)\text{Error = (desired target $-$ actual output)}

which is,

E=1.10.75=0.35E = 1.1 - 0.75 = 0.35

Let’s pause and remind ourselves what the error, the desired target, and the calculated value mean visually.

Get hands-on with 1400+ tech skills courses.