"""Synthetic teaching fixture: NOT measured Jev accuracy or a recommended threshold."""

# (model confidence, predicted team, independently assigned correct team)
development = [(0.95, 'technical', 'technical'), (0.89, 'billing', 'technical'),
               (0.8, 'billing', 'billing'), (0.7, 'technical', 'technical'),
               (0.6, 'billing', 'technical'), (0.4, 'human', 'human')]
held_out = [(0.92, 'technical', 'billing'), (0.83, 'billing', 'billing'),
            (0.55, 'technical', 'technical'), (0.3, 'billing', 'technical')]

def evaluate(rows, threshold, error_cost=10, review_cost=1):
    proposed = [r for r in rows if r[0] >= threshold and r[1] != 'human']
    errors = sum(predicted != label for _, predicted, label in proposed)
    reviewed = len(rows) - len(proposed)
    return {'threshold': threshold, 'n': len(rows), 'proposed': len(proposed), 'errors': errors,
            'coverage': len(proposed) / len(rows) if rows else 0,
            'selective_error': errors / len(proposed) if proposed else None,
            'review_rate': reviewed / len(rows) if rows else 0,
            'cost': errors * error_cost + reviewed * review_cost}

if __name__ == '__main__':
    results = [evaluate(development, t) for t in [0.5, 0.7, 0.8, 0.9, 1.0]]
    for row in results:
        print('development', row)
    chosen = min(results, key=lambda r: (r['cost'], -r['threshold']))['threshold']
    print('held-out (do not retune on this set)', evaluate(held_out, chosen))
    print('Synthetic illustration only. Repeat with labeled outcomes and uncertainty estimates.')
