A non-numeric cell in a numeric column raises a data-dependent exception

オープン
#288 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@hanzalaareeb がすでに取り組んでいます。

2026年11月2日 から。

  • #294 @hanzalaareeb による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
numpy, pandas, python
領域
data

調査の方向性

Start with the unguarded float conversions in dpsynth/local_mode/initialization.py and dpsynth/local_mode/vectorized_transformations.py, then trace how numeric cell values are standardized before histogram aggregation. Reproduce the failure with the provided ? value in the numeric column and check related tests. Done means malformed numeric values are handled consistently with the documented per-row standardization, without a data-dependent exception.

索引モデルが issue の本文から書いたものです。

説明

The accounting philosopy doc states that "During execution, individual cell values (None, NaN, ±∞, out-of-range numbers, or unknown categories) are standardized deterministically per row before any histogram aggregation occurs (by clamping to declared bounds or routing to a dedicated out-of-domain bin), ensuring that malformed records do not raise data-dependent exceptions that break DP.)".

This doesn't appear to be fully the case: a non-numeric value in a numeric column fails because of unguarded casts to floats here and here. Repro:

import io, math
import numpy as np
import pandas as pd
import dpsynth

D = pd.read_csv(io.StringIO("x\n3\n18\n25\n41\n60\n77\n"))
D2 = pd.read_csv(io.StringIO("x\n3\n18\n25\n41\n60\n77\n?\n"))
N, EPS, DELTA = 20, 1.0, 1e-5
schema = dpsynth.Schema({"x": dpsynth.NumericalAttribute(min_value=0, max_value=100)})
mech = dpsynth.calibrate(dpsynth.TabularConfig(discrete_mechanism=dpsynth.discrete_mechanisms.IndependentConfig(pgm_iters=5)),
                         schema, epsilon=EPS, delta=DELTA)

rng = np.random.default_rng(0)
hits = {}
for name, data in (("D", D), ("D'", D2)):
  hits[name] = 0
  for _ in range(N):
    try:
      mech(rng, data)
    except Exception as e:
      hits[name] += 1

p, p2 = hits["D"] / N, hits["D'"] / N
print(f"P_D[E] = {p:.3f}, P_D'[E] = {p2:.3f}; ({EPS}, {DELTA})-DP allows P_D'[E] <= e^eps * P_D[E] + delta = "
      f"{math.exp(EPS) * p + DELTA:.3f}")

prints:

P_D[E] = 0.000, P_D'[E] = 1.000; (1.0, 1e-05)-DP allows P_D'[E] <= e^eps * P_D[E] + delta = 0.000
主要言語
Python
スター
32
フォーク
13
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/dpsynth のほかの issue

google/dpsynth の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。