membership_inference_protection
membership_inference_protection
¶
Classes:
| Name | Description |
|---|---|
MembershipInferenceProtection |
Membership Inference Protection privacy metric. |
MembershipInferenceProtection
pydantic-model
¶
Bases: Component
Membership Inference Protection privacy metric.
Simulates a membership inference attack: can an adversary determine whether a specific record was in the training set by comparing it to the synthetic data? The attack is repeated across multiple similarity thresholds and data proportions for stability.
See Also
https://arxiv.org/abs/2501.03941 -- Synthetic Data Privacy Metrics.
Config:
arbitrary_types_allowed:True
Fields:
-
score(EvaluationScore) -
name(str) -
attack_sum_df(DataFrame | None) -
tps_values(dict[float, int] | None) -
fps_values(dict[float, int] | None)
attack_sum_df = None
pydantic-field
¶
Summary of attack outcomes by protection grade.
tps_values = None
pydantic-field
¶
True positive counts per similarity threshold.
fps_values = None
pydantic-field
¶
False positive counts per similarity threshold.
jinja_context
cached
property
¶
Template context with the membership-inference pie chart figure.
from_evaluation_dataset(evaluation_dataset, config=None)
staticmethod
¶
Run the membership inference attack and return the protection score.
Source code in src/nemo_safe_synthesizer/evaluation/components/membership_inference_protection.py
find_text_fields(df)
staticmethod
¶
Return column names classified as free text.
Source code in src/nemo_safe_synthesizer/evaluation/components/membership_inference_protection.py
embed_text(df)
staticmethod
¶
Embed each text column and average into a single embedding per row.
Source code in src/nemo_safe_synthesizer/evaluation/components/membership_inference_protection.py
divide_tabular_text(df, text_fields)
staticmethod
¶
Split a dataframe into tabular-only and text-only subsets.
Source code in src/nemo_safe_synthesizer/evaluation/components/membership_inference_protection.py
mia(df_train, df_test, df_synth, column_name=None)
staticmethod
¶
Run the full membership inference attack pipeline.
Normalizes data, builds FAISS indexes and/or text embeddings, then repeats the attack across multiple runs for stability. The final score is the average across all runs, mapped to a 0--10 privacy grade.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_train
|
DataFrame
|
Training dataframe. |
required |
df_test
|
DataFrame | None
|
Holdout dataframe (required -- returns unavailable if |
required |
df_synth
|
DataFrame
|
Synthetic dataframe. |
required |
column_name
|
str | None
|
Optional single column to restrict the attack to. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[EvaluationScore, DataFrame | None, dict[float, int], dict[float, int]]
|
Tuple of (score, attack summary dataframe, TP counts, FP counts). |
Source code in src/nemo_safe_synthesizer/evaluation/components/membership_inference_protection.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | |