# The same five scores produced two different review queues

You have time to inspect two of five cases. Their scores are supposed to put the cases that need attention at the top of your list. One case has an undefined score. If it takes the first spot, you get to see only one of the other four.

We tried the same five fictional cases in two programs. We already knew which cases were worth reviewing. DuckDB let the undefined score through its filter and put that case first. PyArrow left it out. As a result, DuckDB showed the reviewer one useful case out of two, and PyArrow showed two.

The programs read scores from Parquet, a file format for storing tables. Each row had a case ID, a confidence score and a label recording whether the case was relevant. To find out how the two lists diverged, we used separate small files to examine what happened before sorting: first when a score wasn’t a usable number, then when it fell outside the promised range.

## Can a missing or undefined score pass a numerical test?

A blank entry is called a null. A calculation may instead produce NaN, short for ‘not a number’, or positive infinity. NaN and infinity can be stored in a numeric column, but neither is a finite number. Even writing the file can change which values survive. In one six-row example PyArrow 26.0.1 turned a NaN into a null when we built the array using `from_pandas=True`. The case IDs, column names and types looked the same afterward.

We opened a file that retained the NaN and asked both programs for scores of at least 0.5. DuckDB 1.4.4 admitted three rows, including the NaN. PyArrow admitted two. Both accepted positive infinity. Requiring the score to be finite as well as at least 0.5 excluded both special values and left the same single case in both programs. [How PyArrow builds an array](https://arrow.apache.org/docs/python/generated/pyarrow.array.html) · [How DuckDB treats special values](https://duckdb.org/docs/1.4/sql/data_types/numeric)

A null can also appear for a different reason. If it turns up after files are merged, [check whether the original files contained the score column](https://sapien1.com/research/check-missing-parquet-columns).

A number that passes the finite check can still fall outside the promised range. A probability must lie between 0 and 1. In a separate file, an irrelevant case had a score of 1.2. Capping it at 1.0 made it tie with a relevant case already at 1.0. Switching from ascending to descending ID order for ties then reversed which case came first. Excluding the invalid score instead kept the relevant case first under either rule. Record which treatment the provider’s definition actually permits. [DuckDB numeric functions](https://duckdb.org/docs/1.4/sql/functions/numeric)

## What the reviewer saw in the five-case queue

Back in the opening example, the case with the NaN was irrelevant. DuckDB had admitted it at the threshold and ranked it first. Only one of the first two cases was relevant (1/2). PyArrow excluded that case at the threshold, and both of its first two were relevant (2/2). That fraction of relevant results among the first two is called precision at two.

Look three places down instead and both programs scored 2/3. Yet the irrelevant case was different in the two lists. Requiring finite scores before sorting made the lists agree in their exact IDs and order at both lengths. [PyArrow filters](https://arrow.apache.org/docs/python/compute.html#filtering-by-expressions)

## When saving fewer digits creates a tie

Ties can also change the ranking in a different kind of review. In a final example an object detector drew two boxes: one around a real object and one false alarm. The correct box scored about 0.5001 and the other 0.5. PyArrow’s float16 number format uses less precision. After conversion, both boxes scored 0.5.

Average precision (AP) rewards placing correct boxes ahead of false alarms. In our test with pycocotools 2.0.10, the box from the lower-numbered image came first once the two scores were tied. When that image contained the false alarm, bounding-box AP fell from 100% to 50%. When it contained the correct box, AP stayed at 100%. After changing a score type, examine the values read back and test the tie rule in the evaluator you use.

Save the versions of the programs that wrote and read the file, the score type, its allowed values, the ranking keys and the rules for ties. Keep the ordered case IDs at the cutoff with the measure and count you report.

If your retention terms allow it, compare those IDs with the last accepted delivery. Matching percentages alone would miss the different irrelevant case in our five-case example.

## Related research

- [Two perfect rankings can put the wrong cases at the front of one queue](https://sapien1.com/research/compare-average-precision)
- [Two mistakes traded places. The detector’s score stayed at 16.83%.](https://sapien1.com/research/check-matching-coco-ap)

[Interpreting test scores](https://sapien1.com/research#scores)
