Blyx modelgate logo # Blyx ModelGate Compare a candidate binary classifier with the model you already ship. ModelGate reads paired predictions on the same observations, writes a JSON report, and sets the process exit code for CI. The gate checks both the cost of mistakes and the quality of the predicted probabilities. ## Try it Download the binary archive for your machine from [releases](https://github.com/Rahulchaube1/blyx-modelgate/releases/tag/v0.1.2), extract it, and run the executable. On Windows use `.\modelgate.exe`; on Linux or macOS use `./modelgate`. The Windows build uses the [Microsoft x64 Visual C++ runtime](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist). ```sh ./modelgate predictions.csv --fn-cost 5 --fp-cost 1 ``` Save this as `predictions.csv`: ```csv label,baseline,candidate 1,0.9,0.4 1,0.8,0.9 0,0.6,0.2 0,0.1,0.1 ``` Both models classify three rows correctly at threshold 0.5. The baseline makes a false alarm and the candidate misses a positive. Charging five times as much for a miss raises cost per row from 0.25 to 1.25. The JSON report records `"pass":false` and the process exits with status 1. The release archive includes this fixture and a passing comparison. ## Input and decision rule Use one held-out observation per row with the literal header `label,baseline,candidate`. Columns contain unquoted numbers. Labels are 0 or 1, predictions are finite probabilities in [0,1], and each pair must refer to the same observation. LF, CRLF, scientific notation, spaces around values, and blank lines are supported. Missing or invalid fields produce a line-numbered error. | Option | Default | Meaning | | --- | --- | --- | | `--threshold` | 0.5 | Predict positive at or above this probability. | | `--fp-cost` | 1 | Cost of a false positive. | | `--fn-cost` | 1 | Cost of a false negative. | | `--brier-tolerance` | 0 | Largest permitted increase in the mean Brier score. | A candidate passes when its cost per row is at most the baseline's and its increase in Brier score is within tolerance. Output includes the options, row count, false positives, false negatives, accuracy, precision, recall, F1, Brier score, and cost per row for each model. Undefined precision, recall, and F1 use the library's zero-denominator convention. Use different tolerances or error costs by passing arguments explicitly in your CI configuration. The comparison allows floating-point roundoff of 1e-14 on Brier score and 1e-14 times the baseline cost on cost per row. A baseline cost of zero therefore still requires a candidate cost of zero. Exit codes are 0 for a pass, 1 for a regression, 2 for invalid input or options, and 4 for a native I/O failure. ModelGate reads a UTF-8 file into memory and scans its records once. Use it for paired binary classification evaluations. A passing report measures the data you supplied and gives no statistical confidence bound. ## Build or extend ```sh git clone --recurse-submodules --branch v0.1.2 https://github.com/Rahulchaube1/blyx-modelgate.git cd blyx-modelgate cargo install --locked --version 0.2.1 blyxc blyxc build main.blyx -o modelgate ./modelgate fixtures/improved.csv ``` Native compilation requires Rust 1.85 or newer and a platform linker. Add `.exe` to the output filename on Windows. The two Git submodules pin the exact classifiers and calibration functions used by this release. In your own Blyx program, import `gate.blyx` and call `gate_passes(baseline_brier, candidate_brier, baseline_cost, candidate_cost, brier_tolerance)` with validated per-observation metrics. [Classification library](https://github.com/Rahulchaube1/blyx-classification) · [Calibration library](https://github.com/Rahulchaube1/blyx-calibration) · [Blyx ecosystem](https://www.blyx-lang.space/packages) ## Contribute Run the documented tests, then open a pull request with a small input that reproduces the behavior you want to change. Include the expected result and your Blyx compiler version. [Package issues](https://github.com/Rahulchaube1/blyx-modelgate/issues) · [Ecosystem catalog](https://www.blyx-lang.space/packages)