Skip to content

feat(probas,#3801): Prong-B Dawid-Skene discriminating-dataset C# demo (Infer-13 §5) - #8360

Merged
jsboige merged 1 commit into
mainfrom
feature/c839-infer13-dawid-skene-prongb
Jul 24, 2026
Merged

jsboige merged 1 commit into
mainfrom
feature/c839-infer13-dawid-skene-prongb

Conversation

@jsboige

@jsboige jsboige commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

Infer-13-Crowdsourcing §5 vote-majoritaire baseline hits 100 % (5/5) on a clean 4-worker dataset: the Biased Worker / Dawid-Skene capability is invisible there (degenerate case — the exact gap PyMC-13 had before #8344). This PR adds a self-contained C# EM demo right after the §5 analysis (cell 27) that makes the capability visible in the numbers.

Discriminating dataset (3 reliable workers + 2 always-1 spammers, 8 items):

  • Majority vote → 75 % (misses items 3 and 7, where 2 spammers + 1 honest error flip the majority to 1)
  • Dawid-Skene EM → 100 % (recovers both items, +2)

The confusion matrices show the spammers correctly deprecated: P(pred=1|vrai=0)=1.0 AND P(pred=1|vrai=1)=1.0 — a vote carrying no information.

Why (Prong-B, #3801)

The §5 dataset is too easy: every worker is reliable, so majority vote is already optimal and Dawid-Skene has nothing to show. The notebook claimed Dawid-Skene's value (cell 27 admits "the real value appears on heterogeneous datasets") but never demonstrated it. This cell builds the biased-worker case where the engine's distinctive capacity (recognize + depreciate non-informative workers) actually changes the outcome. Mirror of the Python twin fix #8344 (PyMC-13 cell 27).

Execution proof (C.2 / H.3)

  • Kernel: .net-csharp (dotnet-interactive), executed via jupyter nbconvert --execute
  • execution_count: 9, 1 consolidated stream-stdout output (real kernel output)
  • Result line: Precision : 100,0% (8 / 8) + >>> Dawid-Skene récupère 2 item(s) (100,0% vs 75,0%)
  • C.1 clean: no NotImplementedException / assert False / 1/0
  • Pure C# (no Infer.NET) → no #r "nuget:" headless blocker

Implementation notes

  • Identical to feat(pymc-13,#3801): Prong-B discriminating Dawid-Skene demo (biased workers) #8344: same dataset (W1 perfect, W2 err item3, W3 err item7, W4/W5 spammers), same diagonal-dominant init (0.8/0.1), 20 EM iterations. (An earlier attempt used a canonical MV-empirical init that landed in a wrong EM basin at 87.5 % — the diagonal-dominant init matching the Python twin converges correctly to 100 %.)
  • ds-prefixed locals (dsTrue, dsLabels, dsConf, dsPost…) to avoid CS0128 scope collision with §5 (nItems, labels, vraisLabels).
  • Inserted after cell[27] (### Analyse du vote majoritaire), before ## 5bis. Exercice.

Byte-stability

  • +166 / 0 pure addition (no existing cell touched)
  • Structural LF (.gitattributes eol: lf, written via write_bytes — avoids Windows write_text CRLF translation)
  • No catalogue churn (COURSE_CATALOG.generated.* untouched)
  • FR-locale decimals (100,0%) consistent with the rest of the Infer series

See #3801 (Prong-B).

…o (Infer-13 §5)

Infer-13-Crowdsourcing §5 vote-majoritaire baseline hits 100% (5/5) on a clean
4-worker dataset: the Biased-Worker / Dawid-Skene capability is invisible
(degenerate case, same gap PyMC-13 had pre-#8344). Add a self-contained C# EM
demo after the §5 analysis (cell 27): 3 reliable workers + 2 always-1 spammers
on 8 items -> majority vote falls to 75% (misses items 3,7), Dawid-Skene EM
recovers 100% (+2 items). Confusion matrices show spammers correctly deprecated
(P(pred=1|vrai=0)=1.0 AND P(pred=1|vrai=1)=1.0 = no information).

Mirror of PyMC-13 #8344 (cell 27): identical dataset, identical diagonal-dominant
init (0.8/0.1), 20 EM iterations. Pure C# (no Infer.NET), ds-prefixed locals to
avoid CS0128 scope collision with §5 (nItems, labels, vraisLabels).

Executed via .net-csharp kernel (dotnet-interactive): ec=9, 1 consolidated
stream-stdout output, real 100,0% (8/8) + matrices. Byte-stable: +166/0 pure
addition, LF structural (.gitattributes eol=lf, write_bytes), no catalog churn.

See #3801 (Prong-B: non-trivial problem that exercises the engine).
@github-actions

Copy link
Copy Markdown
Contributor

Notebook PR Validation: PASS

  • Notebooks checked: 1
  • Code cells validated: 15
  • Result: All passed

Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns)
Non-Python kernels (.NET/Lean): C.1 + errors only (execution_count advisory)
QuantConnect notebooks: C.1 + errors only (require QC Cloud for execution)

@github-actions

Copy link
Copy Markdown
Contributor

Golden-Set Execution (H.7 P3)

✅ 8/8 notebooks passed (certified reproducible)

Notebook Status Time
2.1-Workflow-ML.ipynb ✅ SUCCESS 4.0s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 3.7s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 3.5s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 4.3s
Search-1-StateSpace.ipynb ✅ SUCCESS 4.5s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 2.7s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 20.8s
GameTheory-4c-NashExistence-Python.ipynb ✅ SUCCESS 3.1s

Pinned lockfile: scripts/notebook_tools/golden_set.lock.txt (H.7 P3, axe A #4208)

@clusterManager-Myia clusterManager-Myia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NanoClaw] structural review (glm-5.2 budget: file-list + 1 load-bearing notebook, base-vs-head cell-hash diff, no full patch)

CoursIA #8360 feat(probas,#3801): Prong-B Dawid-Skene discriminating-dataset C# demo (Infer-13 §5)
head fef1ec4d317f, base f79034711e75, +166/-0, 1f Infer-13-Crowdsourcing.ipynb (C# / Infer.NET polyglot). Author jsboige ≠ my identity → 0 self-review conflict. 0 secret, 0 leak, 0 CJK (whole-notebook scan clean).

LGTM deep — this is the canonical motivating example for Dawid-Skene, and it's done right. The §5 baseline (cell [26]) shows majority vote at 100% on clean data, then this PR honestly notes that's "too easy for Dawid-Skene to show its value" and builds the discriminating case where majority vote fails.

Verified by hand:

  • +3 cells add-only (notebook 50→53, 0 deleted → rule 6 ✓): H[28] framing md ("Quand DS surpasse-t-il VRAIMENT MV ?"), H[29] code (discriminating dataset + DS EM), H[30] interpretation. Confirmed via base↔head content-hash diff — exactly these 3 cells are new.
  • Majority vote math (5 workers, true={1,0,1,0,1,0,1,0}, W4/W5 spammers always-1): Item3 votes {0,1,0,1,1}→3 ones vs 2→MV=1, true=0 ✗; Item7 {0,0,1,1,1}→3 vs 2→MV=1, true=0 ✗. → 6/8 = 75%, errors exactly on {3,7}. Matches output byte-for-byte. ✓
  • Dawid-Skene EM — textbook-correct implementation: E-step posterior P(true=k|labels) ∝ 0.5 · ∏_w Conf[w,k,label[w,i]] normalized (canonical product-of-confusion-likelihoods with uniform prior); M-step soft counts Conf[w,k,l] = Σ_i Post[i,k]·𝟙[label[w,i]=l] / Σ_i Post[i,k]; init diagonal-dominant (0.8 / 0.1); 20 iters. ✓
  • Spammer detection sound: converged confusion matrices show W4/W5 with Pred1=1.0 on both Vrai0 and Vrai1 rows → a vote carrying zero information, correctly deprecated by the posterior. W2/W3 show their honest single errors (Vrai0 row 0.75/0.25). DS recovers all 8 → 100%. Output is real EM convergence, not round-number fakes. ✓
  • Interpretation [30] accurate and well-linked (forward to Community §6 + active learning §7 — the deprecated-spammer mechanic is exactly what those generalize).

▼ NIT — ec-doublon (same worker-po pattern flagged ×4 this week). H[29] carries ec=9, but the next code cell [32] also shows ec=9 (and [35] ec=10, etc. unchanged from base). The new cell executed standalone in the existing kernel (output real ✓), but the notebook was not re-run top-to-bottom → non-monotonic sequence 8,9,9,10. A reader doing "Run All" gets correct behavior; the static ec-bookkeeping just looks unrefreshed. Reco: re-execute the notebook top-to-bottom at head so the ec sequence is monotonic. Non-blocking (math + output both sound).

△ Cosmetic: int[,] dsLabels is worker-major (dsLabels[w,i], GetLength(0)=5) — internally consistent and matches the printed W×Item grid; just noting the indexing convention in case a later refactor touches it.

Net: a genuinely well-chosen discriminating dataset (3 reliable + 2 always-1 spammers is the minimal case that breaks MV but not DS) with a correct from-scratch EM. Mergeable; the ec nit is a re-execute polish.

@jsboige
jsboige merged commit f3e5e83 into main Jul 24, 2026
28 of 30 checks passed
jsboige added a commit that referenced this pull request Jul 24, 2026
…clear fleet-red gate) (#8372)

The Twin parity audit gate (#8185 = BLOCKING) was fleet-RED on every open PR
because 15 registered twin pairs drifted on origin/main: merged PRs that modify
a registered twin notebook (citations, Prong-B enrichment, determinism seed,
metadata.cost rollout, nbformat cell-id fix) did not rebaseline their
last_audit.{python,csharp}_sha, so the recorded SHA lagged the merged blob.

G.8 audited resync (NOT rubber-stamped) — every drift traces to a NAMED merged
PR (verified via git log -- <notebook> between recorded and current blob):
  - Coordinated twin updates (parallel PRs both sides): Z3-06 (#8328+#8353),
    ML-7 (#8284 both), Probas-6 (#8366+#8349), Probas-8 (#8330+#8355),
    Probas-11/#8325 both, Probas-13 (#8344+#8360), Probas-15/16/17 citation twins.
  - Framework-specific infra (asymmetric, benign): Probas-3/4/12 C#-only =
    #8323 metadata.cost rollout (PyMC twins have no such frontmatter yet);
    CSP-3 PY-only = #8252 OR-Tools CpSolver seed (C# twin uses Choco Solver,
    deterministic default search — different lib, no parity break, spot-checked);
    Search-3 PY-only = #8324 IDA* prose reframe + #7252 FR accents.
Independently re-confirms the G.1 firsthand claim (jsboige c.03:58, po-2023
c.04:08 merge-sim) on the CURRENT origin/main state (8743caf): all 15 are
stale-sha-only, ZERO content drift that broke semantic parity.

Surgical method (NOT check_twin_parity.py --update): --update yaml.safe_dump's
the ENTIRE curated YAML -> 1350-line churn + strips the header comment block
(measured). Instead: context-free exact string replacement of each old->new
40-char git blob SHA (all 25 old shas unique, verified -> unambiguous). Result:
+25/-25 = 50 lines, ONLY python_sha/csharp_sha fields changed; header comments,
known_differences prose, indentation, LF line-ending byte-preserved (GATE A-C).

Proof: check_twin_parity.py --check -> OK=39 DRIFT=0 exit 0 (CI-green).

See #8264 (resync of existing drifts; 'going-forward enforcement' = documented
precedent #8057, separate concern). See #8057, #8185.

Co-authored-by: Claude <noreply@anthropic.com>
@jsboige
jsboige deleted the feature/c839-infer13-dawid-skene-prongb branch September 2, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants