Find the Annotator Who Mislabels Data
Updated
Problem statement
A labeling team tags items with short text labels, and one of the annotators may be getting many of them wrong. Each row of annotations is one label that an annotator submitted for an item. The raw labels are messy: they may have extra spaces at either end, mixed letter case, or no value at all, and an annotator may have submitted more than once for the same item. reference_labels holds a trusted label for some of the items.
Write rank_annotators(annotations, reference_labels) with pandas. It cleans the data, scores every annotator against the trusted labels, and ranks the annotators so that the most likely mislabeler comes first. Apply these steps in order:
- Clean each label: remove the spaces at its start and end, then make it lowercase. Drop every row whose label is null or is empty after this cleaning.
- If an annotator still has more than one row for the same item, keep only the one with the largest
annotation_id, which is their latest answer. - Keep only rows whose
item_idappears inreference_labels. A kept label is wrong when it is not equal to that item's reference label. - For each annotator with at least one kept row, report
labeled_items(their kept rows),wrong_labels(how many of those are wrong) anderror_rate = wrong_labels / labeled_items.
Return the columns annotator, labeled_items, wrong_labels and error_rate. Sort the rows by error_rate from high to low, then by wrong_labels from high to low, then by annotator in alphabetical order. An annotator with no kept rows does not appear, so the result can be empty. An error_rate within 10^-6 of the exact value is accepted.
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
annotations
| Column | Type | Nullable | Description |
|---|---|---|---|
| annotation_idPK | Integer | No | — |
| item_id | Integer | No | — |
| annotator | Text | No | — |
| label | Text | Yes | — |
reference_labels
| Column | Type | Nullable | Description |
|---|---|---|---|
| item_idPK | Integer | No | — |
| label | Text | No | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| annotator | Text | No | — |
| labeled_items | Integer | No | — |
| wrong_labels | Integer | No | — |
| error_rate | Decimal | No | — |
Row order: must match exactly. Numeric tolerance: 0.000001.
Constraints
annotationshas 1 to 2000 rows, andreference_labelshas 1 to 500 rows.annotation_idvalues are unique positive integers.item_idvalues are positive integers and are unique withinreference_labels.annotatoris 1 to 12 characters long and uses only lowercase letters and digits.- A raw
labelis null or at most 20 characters: letters, with spaces allowed only at the start or the end. - Every reference label is 1 to 15 lowercase letters.
More OpenAI Onsite Interview questions
- Sparse Plant Infection SimulationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Rectangle Point Coverage CountsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Message Event AggregationPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- 15-Minute Chat Session TrackerPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Segmented Durable Key-Value StorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Durable Work Queue OperationsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Versioned Social NetworkPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Budgeted API Inference with Out-of-Order FeedbackONSITE INTERVIEW · Seen Oct 2026
- Plant Infection Simulation, Part 4: Death CountdownPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Count Friend CirclesPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Daily USD Totals with Effective-Dated Exchange RatesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Most Recent Order for Each CustomerCapgemini · ONSITE INTERVIEWCapgemini interview questions
- Tenth-Highest Distinct SalaryInfosys · ONSITE INTERVIEWInfosys interview questions
- Fifth Highest Salary In A DepartmentZS · ONSITE INTERVIEWZS interview questions
- Order Book Data ValidationJane Street · ONSITE INTERVIEWJane Street interview questions
- Nth-Highest Distinct Salary Without Ranking FunctionsMastercard · ONSITE INTERVIEWMastercard interview questions
- Contest Participants with Long Totals and Short QuestionsThe Walt Disney Company · ONSITE INTERVIEWThe Walt Disney Company interview questions
- First Order per Merchant per DateAmazon · ONSITE INTERVIEW
- Block Transaction Count TrendsChainalysis · ONSITE INTERVIEWChainalysis interview questions
- Third-Highest Distinct SalaryExpedia · ONSITE INTERVIEWExpedia interview questions