PromptVersionPassRate (prompt_version_pass_rate v1.0.0)

Copy Markdown View Source

Pass rate per prompt version, with a 95 percent Wilson score range, and a comparison with a baseline version.

Input is a CSV with the columns case_id, version (a label such as v1) and passed (yes or no, any case: whether the output passed YOUR check). Extra columns are ignored. A (case_id, version) pair may appear only once. Version labels are compared as written (after trimming), so v1 and V1 are two versions.

The Wilson score range for k passes out of n cases, with p = k / n and z = 1.96 (fixed), is

centre = (p + z^2 / (2n)) / (1 + z^2 / n)
half   = z * sqrt(p (1 - p) / n + z^2 / (4 n^2)) / (1 + z^2 / n)
range  = centre - half  to  centre + half

Pass rates and differences are exact (integer arithmetic, rounded half up to 1 decimal). The Wilson ends are computed in floating point and rounded to 1 decimal. Two ranges "overlap" when, on the 1-decimal ends as printed, each one starts at or below the point where the other ends. The tool decides nothing: a small number of cases cannot support a conclusion.

Summary

Functions

Signed difference in percentage points, version minus baseline, exact, 1 decimal.

True when two summaries' 1-decimal Wilson ranges overlap.

Parse the CSV text into a list of rows.

Divide num / den * mult exactly (non-negative integers) and format with decimals places, rounding half up. Returns "n/a" when den is zero.

Printable report. baseline must be a version present in the rows, otherwise {:error, message} is returned.

Per-version summary sorted by label: version, cases, passed, and the Wilson ends low and high in tenths of a percent (integers).

95 percent Wilson score range for k passes out of n cases (n > 0), as {low, high} in percent, floats clamped to 0 and 100.

Types

row()

@type row() :: %{case_id: String.t(), version: String.t(), passed: boolean()}

Functions

difference(v, b)

@spec difference(map(), map()) :: String.t()

Signed difference in percentage points, version minus baseline, exact, 1 decimal.

overlap?(a, b)

@spec overlap?(map(), map()) :: boolean()

True when two summaries' 1-decimal Wilson ranges overlap.

parse(text)

@spec parse(String.t()) :: {:ok, [row()]} | {:error, String.t()}

Parse the CSV text into a list of rows.

ratio(num, den, mult, decimals)

Divide num / den * mult exactly (non-negative integers) and format with decimals places, rounding half up. Returns "n/a" when den is zero.

render(rows, baseline)

@spec render([row()], String.t() | nil) :: {:ok, String.t()} | {:error, String.t()}

Printable report. baseline must be a version present in the rows, otherwise {:error, message} is returned.

summarize(rows)

@spec summarize([row()]) :: [map()]

Per-version summary sorted by label: version, cases, passed, and the Wilson ends low and high in tenths of a percent (integers).

wilson(k, n)

@spec wilson(non_neg_integer(), pos_integer()) :: {float(), float()}

95 percent Wilson score range for k passes out of n cases (n > 0), as {low, high} in percent, floats clamped to 0 and 100.