# Blyx Classification Measure the mistakes a binary classifier makes at a decision threshold. The same accuracy can hide very different false-positive and false-negative costs. This library exposes the confusion counts and lets the caller assign the costs. ## Run the example Install the Blyx 0.2.1 CLI, Rust 1.85 or newer, and a system linker. From this repository: ```sh blyxc native-run example.blyx blyxc native-run tests.blyx ``` The example prints precision `0.5`, recall `0.5`, and total cost `6` for one false alarm costing 1 and one missed positive costing 5. ## Use in another Blyx project ```sh git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-classification.git vendor/classification ``` ```blyx use vendor::classification::classification; fn main() { let table = class_confusion([1, 0, 1, 0], [0.9, 0.6, 0.4, 0.1], 0.5); println!(class_cost(at(table, 1), at(table, 3), 1.0, 5.0)); } ``` Save the program beside the `vendor` directory and run `blyxc native-run main.blyx`. For a shared Git project, a submodule can pin the exact library commit. The library has no package dependencies. ## API | Function | Result | | --- | --- | | `class_confusion(labels, scores, threshold)` | Counts in the order TP, FP, TN, FN. One pass over aligned vectors. An empty vector signals invalid input. | | `class_probability(score)`, `class_label(value)` | Check a probability in [0,1] or a binary label 0 or 1. | | `class_positive(score, threshold)` | True when the score meets or exceeds the threshold. | | `class_precision(tp, fp)`, `class_recall(tp, missed)`, `class_f1(tp, fp, missed)` | Binary positive-class metrics. A zero denominator gives 0. | | `class_cost(fp, missed, fp_cost, fn_cost)` | Weighted error cost. Supply counts for totals or rates for cost per observation. | Use equally sized, nonempty vectors, finite probabilities, and a threshold in [0,1]. Supply nonnegative counts and costs to the scalar helpers. Pick a threshold on validation data and evaluate it on separate held-out observations. [Blyx package catalog](https://www.blyx-lang.space/packages) ยท [Blyx compiler](https://github.com/Rahulchaube1/blyxxxx/releases/tag/v0.2.1)