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

Abierto
#288 1 comentario 0 reacciones 0 asignados Ver en GitHub

@hanzalaareeb ya está trabajando en esto.

Desde el 2/11/2026.

  • #294 de @hanzalaareeb — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
numpy, pandas, python
Área
data

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Python
Estrellas
32
Forks
13
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google/dpsynth

Todos los issues de google/dpsynth

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.