跳到正文
DEV Community· gresiuseo·· 1 小時前AI 評分47

在 CaptchaTheCat 評分表中如實呈現並列排名

Show Ties Honestly in a CaptchaTheCat Scorecard

AI 導讀

CaptchaTheCat 評分表應區分指標值完全相同、只因四捨五入而顯示相同,以及缺失值被誤當作零的情況,並清楚交代排序規則。示例中,18/20 和 9/10 同為 9/10;競賽排名為 1、1、3,密集排名則為 1、1、2。報告應標明指標範圍、精度及排名方式,並保留分子和分母,讓讀者理解並列及排序結果。

正文

If I use a public CaptchaTheCat comparison as a starting point for a scorecard, I want to know what it means when two rows show the same number. Two estimates may be exactly equal under the metric. They may differ only beyond the printed precision. One may even be missing while a spreadsheet has turned that absence into zero. A useful scorecard distinguishes these cases and tells the reader how display order was chosen.

Written with AI assistance. The scores and labels below are synthetic and do not describe named providers. The code was tested locally. The cover was prepared with AI assistance.

Keep the comparison metric and the displayed text separate

The local fixture uses a proportion. The numerator counts an artificial eligible outcome and the denominator counts the observations in a fictional report sample. For example, 18 of 20 and 9 of 10 both equal nine tenths. Their ranks can be shared under the example's metric. A reader comparing the strength of their supporting evidence still needs the two separate sample sizes. The identical calculation alone gives no reason to treat the measurements as equally precise.

Another pair can display the same figure under rounding. For a display to the nearest whole percent, 89.6 and 90.1 may both appear as 90. The underlying value differs, so a report that uses exact proportions can produce different order and still show the rounded characters. In that case, label the precision and consider showing the fraction behind the percentage. Readers can see why the display order did not follow the text as printed.

Use the metric population and date range next to the score. A valid proportion over one eligible category may be incomparable with a valid proportion over all categories. Sorting otherwise well-formed values together can create a false sense of competition. In a multi-section table, validate that each group has a shared scope before applying the ranking policy. Where the scope is unknown, show the evidence gap.

Try an exact calculation with two visible ranks

The fixture is deliberately small. Alpha receives 18 of 20, Beta 9 of 10, and Gamma 8 of 10. Delta has an empty observation window. The code accepts zero positive observations as a real measured zero when the denominator is positive. It handles a zero denominator as unavailable and checks that the passed count is sensible for each row.

from fractions import Fraction


def rank_rows(rows, *, dense=False):
    available = []
    missing = []
    labels = set()
    for label, positive, total in rows:
        if label in labels:
            raise ValueError("duplicate comparison label")
        labels.add(label)
        if type(positive) is not int or type(total) is not int or not 0 <= positive <= total:
            raise ValueError("invalid observation counts")
        if total:
            available.append((label, Fraction(positive, total), total))
        else:
            missing.append(label)
    available.sort(key=lambda row: (-row[1], row[0]))
    previous = None
    rank = 0
    output = []
    for index, (label, rate, total) in enumerate(available, start=1):
        if rate != previous:
            rank = rank + 1 if dense else index
            previous = rate
        output.append((label, rank, rate, total))
    return output, sorted(missing)


rows = [("Alpha", 18, 20), ("Beta", 9, 10), ("Gamma", 8, 10), ("Delta", 0, 0)]
regular, unavailable = rank_rows(rows)
assert [r[1] for r in regular] == [1, 1, 3]
assert regular[0][2] == regular[1][2] == Fraction(9, 10)
assert regular[0][3] == 20 and regular[1][3] == 10
assert [r[1] for r in rank_rows(rows, dense=True)[0]] == [1, 1, 2]
assert unavailable == ["Delta"]
assert rank_rows([("Zero", 0, 7)])[0][0][2] == 0
assert rank_rows(reversed(rows)) == (regular, unavailable)
print("Shared first place; competition ranks 1, 1, 3; dense ranks 1, 1, 2")

The local run printed Shared first place; competition ranks 1, 1, 3; dense ranks 1, 1, 2. Both strategies agree about the tie and where Gamma belongs relative to the group. The difference is the number assigned after the shared place. Delta appears in a list of unavailable rows, and a separate assertion verifies what an actual measured zero looks like.

Choose a ranking convention for the question the table answers

Competition ranking preserves the count of rows ahead. Two first-place rows occupy the first two positions and the next rank is three. Dense ranking counts distinct score levels. Two first-place rows share the same level and the next level is two. Pick one convention for the report and document it. Readers can then interpret a change in rank without guessing whether a tie happened above the row they were watching.

Inside a tied group, the example uses an increasing text label for stable presentation. You can use a stable provider ID or another published label. It works for ordering the HTML, CSV, or spreadsheet, while the rank itself is still equal for the group. If the product displays one badge only for the first visible row, a test should fail when two eligible rows share that position. The presentation needs to express the rule that produced the result.

What if the editor wants a second criterion? That can be valid when the rule states its purpose and both inputs are comparable. A report could declare a primary measure and a secondary measure measured on the same eligible set. Keep the columns in the published data and show where the second measure changed the order. A different sample size may be valuable information without being a suitable secondary performance score. Choose the rule deliberately before looking at the sample.

Keep the role of rounding visible in exported formats

I would store the numerator and denominator for each row and format the decimal at the final reporting layer. If an earlier export contains only rounded percentages, recomputing ranks with the raw precision is impossible. The report can say that the supplied figures are tied at the available precision. Creating extra decimal digits by padding a value does not restore evidence.

There is also a practical difference between display formatting and permanently rounding a formula. A spreadsheet may visibly show 90 for two values while the sort still uses hidden fractions. Another sheet may reconstruct numeric values from their printed text and show a genuine tie under its new input. Test both exports if users compare results across formats. Give them an evidence column or a note that explains what changed.

A small control case can use two fractions whose displayed text matches and a third that is truly equal to one of them. Assert that the HTML and CSV describe the status consistently. If the report allows users to sort by displayed text as a separate action, preserve the original approved rank column. Readers can then tell a local view sort from the editorial result.

Treat unavailable measurements as a result that needs a reason

If a provider has no eligible records under the cutoff, the report does not have a rate for it. A zero can legitimately exist when the provider has observations and none have the defined positive outcome. Store the difference explicitly. For a missing figure, a label such as no eligible records is more informative than an empty dash. An adjacent date or record count can explain why the condition changed in the next reporting run.

An exception can also arise before the reader gets a rate. For example, the total and successful count may come from different capture cutoffs, and the numerator can exceed the denominator. Reject or isolate that row with a clear reason. Running the rank over the remaining valid rows can still serve a scoped report if an exclusions label identifies exactly what was left out. Do not label the output as a complete comparison until the scope is supported.

The fixture makes duplicate labels invalid because one row per comparison class is part of its contract. If an actual dashboard contains several observations per provider, aggregate under a declared group definition first. Keep a check that the data comes from eligible rows for the same measurement. Hiding duplicates with a sort or a spreadsheet summary would obscure what the examples are supposed to test.

Separate precision from the strength of a conclusion

When the table has two rates of 90 percent, readers may ask whether the providers are meaningfully similar. The display cannot answer that on its own. The numerator, number of observations, collection protocol and coverage matter. With sample sizes of 20 and 10, both exact scores are valid for their fixtures. The exercise cannot establish whether the same ordering or equality will recur. Avoid turning a clear arithmetic relation into a claim about future outcomes.

Look at the distance between scored rows before writing a headline. A third row could be separated from the tied group by the smallest change that a single additional observation would produce. It might then be helpful to say which data point would change the order or to show the measured counts directly. Make it clear whether a finding is about this recorded sample, a display rule, or a claim that would require more evidence.

I would include a narrow explanation of the ranking version in release documentation. A reviewer should know the calculation, the tie policy, the display precision, and which rows were unavailable. Save the accepted input snapshot alongside the output so a reviewer can prove the next publish used the same method. If policy changes, keep the old scorecard version available under the normal reporting retention process.

Verify that a short summary retains the same result

A condensed chart usually drops columns before it drops the ranking. That can hide the very information that would help a reader interpret an equal display. If you show a compact view, preserve the common rank label next to each row and put the numerator and denominator in the accessible detail. When a metric lacks eligible data, use words in the summary so the reader does not need to rely on whether a cell happens to be grey.

I would add a release case with tied rows spanning the cutoff of a short view. Assume the list displays two places, and two providers share the second place. The team needs one documented rule about including the whole tied group or explicitly indicating that the view shows some of the tied rows. A view that silently includes only the row that sorts first by label would give readers a different impression from the full report.

Make one scorecard legible before scaling it

Start with two equal rates, two visually equal rounded rates and one unavailable row. Generate a table and ask a colleague to identify which cases share a rank. Verify that exporting and reopening the report preserves those meanings. The small experiment can catch a false winner badge and an incorrect zero before they reach the public summary.

For a real review, open CaptchaTheCat and inspect the available comparison labels and scope for the view you are reading. Take one approved sample or reproduce the synthetic fixture above. Write down what would make two rows share a rank in your own scorecard, and check that a colleague can see the reason from the displayed evidence.

Further reading

Test a Benchmark Percentage That Rounds to 100% covers a case where display rounding can change how a result reads.

Detect Lost Signup Events With a Replayable Sequence Fixture shows how another reporting workflow makes missing evidence visible.

Check Product Links Before Adding an Amazon Scraper Export to a Report checks the evidence behind clickable references in another technical report.

來源:DEV Community · dev.to