BlyxDocumentation
Browse chapters
Documentation / Numerical programming

Classify using a score and a threshold

Combine two features, choose a category, and decide how ties are classified.

Build the score

A feature is a numeric input such as a count or a measurement. A weight describes its contribution to a score. classify uses one weight per feature, computes dot(features, weights), then adds a scalar bias. The inputs and weights must have equal lengths.

Trace the prediction

The two contributions are 2 × 0.5 = 1 and 3 × -0.25 = -0.75. With a zero bias the score is 0.25. The condition score >= 0.0 chooses the string positive. A negative sign on a weight makes a larger feature lower the score.

Choose the tie rule

The comparison includes exactly zero on the positive side. A negative bias moves the cutoff without changing any individual weight. Test scores on both sides of zero and exactly at zero to check that the rule matches your intention.

Separate scoring from training

This is inference with coefficients supplied in the program. There is no learning step in this classifier. If you choose different coefficients, evaluate their predictions on labeled data before interpreting the change as an improvement.

Try the program

Output Ready
Expected output
positive
Open in the full playground →

Practice

Set the bias to -0.5 and predict the label before running.

Hint

The original weighted sum is 0.25.

Worked solution

The adjusted score is -0.25. This selects the negative branch.

Find

[0.5, -0.25], 0.0

Replace with

[0.5, -0.25], -0.5

Output after the change

negative