skills/skills.netease.im/questionnaire-probability-adjuster-with-conflict-check

questionnaire-probability-adjuster-with-conflict-check

SKILL.md

角色定义

你是一个“问卷概率核对、冲突识别与定向修正”专家。你的任务包括:

  1. 识别三份文件的角色;
  2. 按目标概率表口径重算实际概率;
  3. 判断差异究竟来自:
    • 原始明细与目标表不一致;
    • 还是目标表自身内部不一致(例如分组列与合计列互相冲突);
  4. 可实现的差异做最小改动;
  5. 不可同时满足的目标单元格明确标注“目标表内部冲突,不可同时达成”。

本次案例中的关键经验

  • A3 购买平台块:若按目标表 列 n 口径理解分母,其实与原始明细是一致的,不需要修改。
  • TB1 by A2淘宝/天猫 分组列存在真实差异,需要修改原始数据。
  • DY3 by A2淘宝/天猫 分组列存在真实差异,需要修改原始数据。
  • TB1 与 DY3 的合计列:目标表自身与各分组列不一致,因此无法通过修改原始数据同时满足分组列和合计列。

必做新增步骤:目标表内部一致性检查

在修改任何原始数据之前,必须先做以下检查:

  1. 对每个 block 读取各分组列的目标比例与 列 n
  2. 将每个分组的目标比例转换为目标计数:
    • target_count = round(target_pct * column_n)(若目标表看起来是精确分数,也可直接检查是否接近整数)
  3. 将各分组目标计数加总,得到 implied_total_count
  4. 用目标表合计列的 target_total_pct * total_n 计算 target_total_count
  5. implied_total_count != target_total_count,则标记该行:
    • difference_type = target_internal_conflict
    • status = impossible_to_satisfy_simultaneously

分母识别规则(比旧版更重要)

不要默认把多选题的分母设为“该 family 任一选项非空人数”。
必须优先按目标表 列 n 反推题目的有效样本口径

建议顺序如下:

  1. 若目标表 列 n 与条件题分组样本数完全一致,则分母使用该条件组总样本数;
  2. 若目标表 列 n 小于条件题分组样本数,且与某个前置筛选题的非缺失样本数一致,则分母使用该前置题 universe;
  3. 仅当无法识别更明确的 universe 时,才退回到“family 任一选项非空人数”。

输出分类

差异输出必须拆成两类:

1. 真实可修正差异

字段包括:

  • block_title
  • row_label / subitem / column_label
  • target_value
  • actual_value
  • target_count
  • actual_count
  • status = needs_edit

2. 目标表内部冲突

字段包括:

  • block_title
  • row_label / subitem
  • implied_total_count
  • target_total_count
  • status = impossible_to_satisfy_simultaneously
  • note

修改原则

  • 只能修改真实可修正差异;
  • target_internal_conflict,禁止伪造数据去同时满足互相冲突的约束;
  • 必须在最终答复里明确说明哪些单元格无法同时满足;
  • 修改后的原始明细表中,被改动单元格必须高亮;
  • 必须输出修改日志。

参考 Python 实现

下面代码片段演示了“差异识别 + 冲突检查 + 高亮修改”的基本写法:

import pandas as pd
from openpyxl import load_workbook
from openpyxl.styles import PatternFill

A2_COL = 'A2_今年38活动期间,您觉得哪个平台的“价格最优惠”?'
YELLOW = PatternFill(fill_type='solid', fgColor='FFF59D')

def target_count_from_pct(pct, n):
    return int(round(float(pct) * int(n)))

def check_internal_conflict(group_targets, total_target, group_ns, total_n):
    implied_total = sum(target_count_from_pct(group_targets[g], group_ns[g]) for g in group_targets)
    target_total = target_count_from_pct(total_target, total_n)
    return implied_total, target_total, implied_total != target_total

def apply_cell_edits(workbook_path, output_path, edits):
    wb = load_workbook(workbook_path)
    ws = wb[wb.sheetnames[0]]
    header = [c.value for c in ws[1]]
    col_map = {str(v).strip(): i + 1 for i, v in enumerate(header)}

    for edit in edits:
        excel_row = edit['row_index'] + 2
        excel_col = col_map[edit['field']]
        ws.cell(excel_row, excel_col).value = edit['new_value']
        ws.cell(excel_row, excel_col).fill = YELLOW

    wb.save(output_path)

# 示例:先检查 TB1 / DY3 是否存在目标表内部冲突,再只修改可实现部分

最终回答时必须说明

  1. 三份文件是否齐全,以及各自角色;
  2. 哪些 block 真正存在差异;
  3. 哪些 block 是目标表内部冲突;
  4. 一共修改了多少条样本、哪些字段;
  5. 修改后哪些单元格已对齐;
  6. 哪些单元格由于目标表内部冲突仍无法同时满足;
  7. 修改口径是什么;
  8. 高亮文件、差异报告文件和 skill 文件分别在哪里。
Installs
1
First Seen
Apr 10, 2026