From bfb7b6df93cbdb21ef9f36d8c5840a5c165f53a6 Mon Sep 17 00:00:00 2001 From: jsboige Date: Fri, 18 Sep 2026 05:26:17 +0200 Subject: [PATCH 1/4] feat(probas,#16620): Infer-5 effets naturels NDE/NIE calcules + correction raccourcis CDE (P5a) Nouvelle cellule : NDE = 0,280 et NIE = 0,180 par enumeration sur le SCM de mediation (X formation -> M competences -> Y promotion), NDE + NIE = 0,460 = TE exactement -- identite algebrique de telescopage. Correction (G.1) : le markdown affirmait NDE = CDE(M=0) = 0,300 et NIE = TE - NDE = 0,160 avec une verification tautologique (NIE defini comme TE - NDE). Mesure : NDE = 0,280 != CDE(0) = 0,300 et part mediee vraie 0,180 != 0,160 -- l'interaction X*M (CDE(1) = 0,200 vs CDE(0) = 0,300) casse les raccourcis via CDE, pas l'identite NDE + NIE = TE. exec_dotnet_persist 16/16 cells, 0 erreur, exec counts consecutifs, validator PASS, catalogue intact. See #16620 Co-Authored-By: Claude Sonnet 5 --- .../Infer/Infer-5-Causal-Inference.ipynb | 307 +++++++++++++++++- 1 file changed, 293 insertions(+), 14 deletions(-) diff --git a/MyIA.AI.Notebooks/Probas/Infer/Infer-5-Causal-Inference.ipynb b/MyIA.AI.Notebooks/Probas/Infer/Infer-5-Causal-Inference.ipynb index a6b75742f2..085cde8175 100644 --- a/MyIA.AI.Notebooks/Probas/Infer/Infer-5-Causal-Inference.ipynb +++ b/MyIA.AI.Notebooks/Probas/Infer/Infer-5-Causal-Inference.ipynb @@ -75,12 +75,127 @@ "outputs": [ { "output_type": "display_data", - "metadata": {}, + "data": { + "text/html": [ + "\r\n", + "
\r\n", + " \r\n", + " \r\n", + "
" + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", "data": { "text/html": [ "
Installing Packages
  • Microsoft.ML.Probabilistic
  • Microsoft.ML.Probabilistic.Compiler
" ] - } + }, + "metadata": {} }, { "output_type": "stream", @@ -200,17 +315,16 @@ }, { "output_type": "display_data", - "metadata": {}, "data": { "text/html": [ "\n", "
\n", - "
Model_06_29_26_12_25_36_48.svg
\n", + "
Model_09_18_26_05_25_38_96.svg
\n", "
\n", " \r\n", "\r\n", - "\r\n", "\r\n", "\n", "
" ] - } + }, + "metadata": {} }, { "output_type": "stream", @@ -1445,6 +1560,166 @@ "Console.WriteLine($\" -> part mediee (indirect) ~= TE - CDE(M=0) = {TE - CDE0:F3} (chemin via les competences)\");" ] }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Compiling model..." + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "done.\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Compiling model..." + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "done.\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Compiling model..." + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "done.\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Compiling model..." + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "done.\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Compiling model..." + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "done.\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Compiling model..." + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "done.\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Effets naturels (Pearl 2001) sur le SCM formation -> competences -> promotion :\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + " NDE = 0,280 (effet direct, mediateur naturel sous X=0)\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + " NIE = 0,180 (effet indirect, Y evalue sous X=1)\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + " NDE + NIE = 0,460 vs TE = 0,460 -> ecart |TE - NDE - NIE| = 0,000\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + " Raccourci CDE : NDE =? CDE(0) -> 0,280 vs 0,300 ; part mediee =? TE-CDE(0) -> 0,180 vs 0,160\r\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + " (NDE + NIE = TE : identite algebrique ; ce qui derive, ce sont les raccourcis via CDE)\r\n" + ] + } + ], + "source": [ + "// EFFETS NATURELS (Pearl 2001) : NDE et NIE calcules sur le SCM de mediation ci-dessus.\n", + "// Pas de confondeur M <- U -> Y : la sequential ignorability tient, les quantites\n", + "// \"cross-world\" se calculent par enumeration sur le meme SCM (monde imbrique).\n", + "// P(M=m | do(X=x)) : le mediateur sous intervention (CPT direct du SCM)\n", + "double PM_doX(bool xVal, bool mVal) {\n", + " double pM1 = xVal ? 0.80 : 0.20;\n", + " return mVal ? pM1 : 1.0 - pM1;\n", + "}\n", + "\n", + "// NDE_{0,1} = Somme_m P(m|do(0)) * [P(Y|do(1),do(m)) - P(Y|do(0),do(m))]\n", + "// (mediateur a sa valeur NATURELLE sous X=0, pas figee -- c'est le contrefactuel imbrique)\n", + "double NDE = PM_doX(false, true) * (PY_doX_doM(true, true) - PY_doX_doM(false, true))\n", + " + PM_doX(false, false) * (PY_doX_doM(true, false) - PY_doX_doM(false, false));\n", + "\n", + "// NIE_{1,0} = Somme_m [P(m|do(1)) - P(m|do(0))] * P(Y=1|do(1),do(m))\n", + "// (Y sous X=1, seul le CHANGEMENT du mediateur porte l'effet)\n", + "double NIE = (PM_doX(true, true) - PM_doX(false, true)) * PY_doX_doM(true, true)\n", + " + (PM_doX(true, false) - PM_doX(false, false)) * PY_doX_doM(true, false);\n", + "\n", + "Console.WriteLine(\"Effets naturels (Pearl 2001) sur le SCM formation -> competences -> promotion :\");\n", + "Console.WriteLine($\" NDE = {NDE:F3} (effet direct, mediateur naturel sous X=0)\");\n", + "Console.WriteLine($\" NIE = {NIE:F3} (effet indirect, Y evalue sous X=1)\");\n", + "Console.WriteLine($\" NDE + NIE = {NDE + NIE:F3} vs TE = {TE:F3} -> ecart |TE - NDE - NIE| = {Math.Abs(TE - NDE - NIE):F3}\");\n", + "Console.WriteLine($\" Raccourci CDE : NDE =? CDE(0) -> {NDE:F3} vs {CDE0:F3} ; part mediee =? TE-CDE(0) -> {NIE:F3} vs {TE - CDE0:F3}\");\n", + "Console.WriteLine(\" (NDE + NIE = TE : identite algebrique ; ce qui derive, ce sont les raccourcis via CDE)\");" + ] + }, { "cell_type": "markdown", "id": "infer22-mediation-interp", @@ -1462,10 +1737,14 @@ "- **NIE (Natural Indirect Effect)** = `Y_{1,M_{X=1}} - Y_{1,M_{X=0}}` : effet indirect transmis par le changement \"naturel\" de `M` quand `X` bascule de 0 a 1.\n", "- **TE = NDE + NIE** (decomposition additive, Pearl 2001, Robins & Greenland 1992).\n", "\n", - "Dans Infer.NET, le NDE/NIE **necessite une hypothese supplemental** : la **sequential ignorability** (ou *cross-world independence*) sur les contrefactuels `M_{X=x'}` -- c'est-a-dire que la distribution de `M` sous `do(X=x')` reste compatible avec le meme SCM. Sur notre SCM de mediation (`X -> M -> Y`, pas de confondeur `M <- U -> Y`), cette hypothese tient et **NDE = CDE a M=M\\_{X=0}**, **NIE = TE - NDE**. Avec les valeurs mesurees : **NDE = CDE(M=0) = 0,300**, **NIE = TE - NDE = 0,460 - 0,300 = 0,160** -- la part mediee est exactement l'ecart observe. **Verification immediate** :\n", + "Dans Infer.NET, le NDE/NIE **necessite une hypothese supplemental** : la **sequential ignorability** (ou *cross-world independence*) sur les contrefactuels `M_{X=x'}` -- c'est-a-dire que la distribution de `M` sous `do(X=x')` reste compatible avec le meme SCM. Sur notre SCM de mediation (`X -> M -> Y`, pas de confondeur `M <- U -> Y`), cette hypothese tient : les effets naturels sont **calculables par enumeration sur le meme SCM** (cellule suivante). Les valeurs mesurees : **NDE = 0,280**, **NIE = 0,180**, et **NDE + NIE = 0,460 = TE** -- une **identite algebrique** (le telescopage des deux sommes rend la decomposition exacte pour tout SCM discret), pas une coincidence.\n", + "\n", + "Ce que l'interaction X*M casse en revanche, ce sont les **raccourcis via le CDE** : notre monde a CDE(1) = 0,200 != CDE(0) = 0,300, donc **NDE != CDE(0)** (0,280 vs 0,300) et la \"part mediee\" TE - CDE(M=0) = 0,160 sous-estime le vrai NIE = 0,180 :\n", "\n", "```\n", - "NDE + NIE = CDE(M=0) + (TE - CDE(M=0)) = TE ✓ (decomposition de Pearl 2001)\n", + "NDE + NIE = TE (exacte, toujours -- identite de telescopage)\n", + "NDE = CDE(m) (faux des que CDE varie en m : interaction)\n", + "part mediee = TE - CDE(M=0) (approximation : 0,160 au lieu de 0,180 ici)\n", "```\n", "\n", "**Quand CDE != NDE** : si un confondeur `U` influence **a la fois** `M` et `Y` (par exemple, le \"motivation\" qui determine a la fois les competences acquises ET la reconnaissance patronale), CDE a `do(M=0)` ne capture pas l'effet direct reel -- il faut le **NDE**, qui requiert des methodes d'inference contrefactuelle specifiques (voir section 10 et la discussion dans Pearl 2001, sec. 4). Infer.NET, comme moteur de message passing determinant sur graphes discrets, rend ce cas plus difficile (les contrefactuels \"cross-world\" sortent du formalisme d'un seul DAG).\n", @@ -1514,7 +1793,7 @@ "cell_type": "code", "id": "7300698aebb9", "metadata": {}, - "execution_count": 11, + "execution_count": 12, "outputs": [ { "output_type": "stream", @@ -1659,7 +1938,7 @@ "cell_type": "code", "id": "eb5112fe221d", "metadata": {}, - "execution_count": 12, + "execution_count": 13, "outputs": [ { "output_type": "stream", @@ -1698,7 +1977,7 @@ "cell_type": "code", "id": "b1ec24f8fe8a", "metadata": {}, - "execution_count": 13, + "execution_count": 14, "outputs": [ { "output_type": "stream", @@ -1736,7 +2015,7 @@ "cell_type": "code", "id": "deeb4d1f5bc6", "metadata": {}, - "execution_count": 14, + "execution_count": 15, "outputs": [ { "output_type": "stream", @@ -1772,7 +2051,7 @@ "cell_type": "code", "id": "1f39b5a055ca", "metadata": {}, - "execution_count": 15, + "execution_count": 16, "outputs": [ { "output_type": "stream", @@ -1890,4 +2169,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file From ea686739e49c72b66c49f034c7ba226eb39fa34d Mon Sep 17 00:00:00 2001 From: jsboige Date: Sun, 20 Sep 2026 00:19:21 +0200 Subject: [PATCH 2/4] chore(twin-parity,#16639): attest Probas-5 Causal-Inference pair at current head (Infer-5 P5a) Guard-demanded rebaseline (selector --pair, lessons L963/L974): 1 pair updated. Entry index 0014; the posterior twin PR (#16640 P5b) takes 0015 to avoid concurrent index collision (memory twin-registry-concurrent-index-collision). Co-Authored-By: Claude Sonnet 5 --- .../0014-2026-09-20-myia-po-2023-CoursIA.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 scripts/notebook_tools/twin_pairs.d/probas-5-causal-inference/0014-2026-09-20-myia-po-2023-CoursIA.yaml diff --git a/scripts/notebook_tools/twin_pairs.d/probas-5-causal-inference/0014-2026-09-20-myia-po-2023-CoursIA.yaml b/scripts/notebook_tools/twin_pairs.d/probas-5-causal-inference/0014-2026-09-20-myia-po-2023-CoursIA.yaml new file mode 100644 index 0000000000..55b72a1b6e --- /dev/null +++ b/scripts/notebook_tools/twin_pairs.d/probas-5-causal-inference/0014-2026-09-20-myia-po-2023-CoursIA.yaml @@ -0,0 +1,6 @@ +date: '2026-09-20' +by: myia-po-2023:CoursIA +python_sha: 4acbd60f320c12f5e91fdd6c3fd68bfb32bddbf8 +csharp_sha: 4cbc0fc3f75e5213cee9d807f8bca25891a08078 +content_python_sha: 6e39eb98b22079088c123682ae89bfedf71d089de13357e34e4a51f96380c1ba +content_csharp_sha: f9e0d1c5a5e972fbd93f323c295b4d5e2257c6b023e1749a3f03c98454953187 From 33209f6c2527f14401dd94280bbf6e1302b14ad6 Mon Sep 17 00:00:00 2001 From: jsboige Date: Sun, 20 Sep 2026 00:20:40 +0200 Subject: [PATCH 3/4] fix(infer,#16639): strip kernel-injected probeAddresses banner (9 lines, output-only) Rule-6 exception (kernel-bootstrap noise, #2733/#6312 precedent): source byte-identical, stream outputs + execution_count preserved. Re-exec cannot cure (re-injects). Strip precedes twin re-attestation per #8957. Co-Authored-By: Claude Sonnet 5 --- .../Infer/Infer-5-Causal-Inference.ipynb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/MyIA.AI.Notebooks/Probas/Infer/Infer-5-Causal-Inference.ipynb b/MyIA.AI.Notebooks/Probas/Infer/Infer-5-Causal-Inference.ipynb index 4cbc0fc3f7..7877c558e8 100644 --- a/MyIA.AI.Notebooks/Probas/Infer/Infer-5-Causal-Inference.ipynb +++ b/MyIA.AI.Notebooks/Probas/Infer/Infer-5-Causal-Inference.ipynb @@ -83,7 +83,7 @@ " The below script needs to be able to find the current output cell; this is an easy method to get it.\r\n", "
\r\n", " \r\n", From 9491ecc21b0bda95c13ddf7a4231babed73dd653 Mon Sep 17 00:00:00 2001 From: jsboige Date: Sun, 20 Sep 2026 00:20:52 +0200 Subject: [PATCH 4/4] chore(twin-parity,#16639): re-attest Probas-5 Causal-Inference AFTER banner strip (#8957) The strip moved the committed blob SHA; the 0014 entry attested the pre-strip state. 0015 records the post-strip blob. Posterior twin (#16640) moves to 0016. Co-Authored-By: Claude Sonnet 5 --- .../0015-2026-09-20-myia-po-2023-CoursIA.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 scripts/notebook_tools/twin_pairs.d/probas-5-causal-inference/0015-2026-09-20-myia-po-2023-CoursIA.yaml diff --git a/scripts/notebook_tools/twin_pairs.d/probas-5-causal-inference/0015-2026-09-20-myia-po-2023-CoursIA.yaml b/scripts/notebook_tools/twin_pairs.d/probas-5-causal-inference/0015-2026-09-20-myia-po-2023-CoursIA.yaml new file mode 100644 index 0000000000..78c97f3642 --- /dev/null +++ b/scripts/notebook_tools/twin_pairs.d/probas-5-causal-inference/0015-2026-09-20-myia-po-2023-CoursIA.yaml @@ -0,0 +1,6 @@ +date: '2026-09-20' +by: myia-po-2023:CoursIA +python_sha: 4acbd60f320c12f5e91fdd6c3fd68bfb32bddbf8 +csharp_sha: 7877c558e8bd28501ff29fdb8eaeb8c0b01fa813 +content_python_sha: 6e39eb98b22079088c123682ae89bfedf71d089de13357e34e4a51f96380c1ba +content_csharp_sha: 110de8f995927c1295cd84faf922ab15df5a186e89008cf72dc147151b70d8c4