Skip to content

feat(nb,#12455): 2.3b — Naive Bayes generatif vs regression logistique discriminative (volet 1/3) - #12664

Merged
myia-ai-01 merged 1 commit into
mainfrom
feature/12455-nb-generatif
Aug 24, 2026
Merged

feat(nb,#12455): 2.3b — Naive Bayes generatif vs regression logistique discriminative (volet 1/3)#12664
myia-ai-01 merged 1 commit into
mainfrom
feature/12455-nb-generatif

Conversation

@jsboige

@jsboige jsboige commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Grain: MED/notebook-python — lane myia-po-2024:CoursIA-2 — prev: MED/notebook-python #12659

Résumé

Nouveau notebook 2.3b-Naive-Bayes-Generatif.ipynb (02-ML-Cours, volet 1/3 de #12455) : le classifieur génératif Naive Bayes n'était jamais enseigné dans la série. On l'implémente de zéro, on le vérifie contre sklearn, puis on le met en face de la régression logistique (le discriminatif de 2.3) sur le compromis génératif-discriminatif (Ng & Jordan, 2002) — mesuré, pas raconté (Prong-B).

  • §1 — Naive Bayes gaussien from scratch : classe MyGaussianNB (~15 lignes, log-vraisemblance + priors). Vérification contre GaussianNB : même précision 0.925, prédictions identiques bit à bit, moyennes de classe égales (décalage de l'ordre de +1 sur la classe 1).
  • §2 — Deux scénarios mesurés, deux régimes (40 graines, jeu de test fixe) :
    • Scénario A (corrélation homogène, hypothèse à peu près vraie) : NB +0.09 à n=30, écart fond à ~0.001 à n=1920 → l'avantage génératif est une signature du petit échantillon.
    • Scénario B (corrélation en bloc forte, hypothèse d'indépendance fausse) : NB figé ~0.745 dès n≈120 (mur de biais), logistique s'échappe 0.70→0.82, écart jusqu'à **-0.076** → le discriminatif gagne quand son hypothèse est fausse et que les données abondent.
  • §3 — Table de décision mesurée : 4 situations, le compromis, la mesure.
  • 3 exercices (C.1 conformes : None # TODO etudiant + print) : multinomial NB de zéro, effet de la dimension, reconnaissance du régime.

Validation

  • Ré-exécuté end-to-end via papermill (kernel python3), RC=0, 9 cellules code sans erreur.
  • C.1 : aucun raise NotImplementedError / assert False / 1/0.
  • C.2 + H.3 : chaque cellule code porte execution_count et outputs (séquence 1–9, aucun null).
  • Prong-B mesuré (G.9) : prose alignée sur les sorties réelles après re-exécution — valeurs affichées, pas un folklore. La signature make_block(n, d, shift, rho, rng) est fixée pour que les scénarios tournent avec les paramètres annoncés (rho/shift non inversés).
  • Aucun chemin machine dans les sorties (AppData / jsboi / C:/Users absents).
  • Catalogue et fichiers générés non touchés (un seul fichier dans le diff).

Complète le volet 1/3 : #12455 (socle classique ML) est désormais entièrement livré via #12652 (clustering, 2/3), #12659 (hypothèses régression, 3/3) et cette PR (naive Bayes, 1/3).

See #12455

…ative

Nouveau notebook 2.3b qui complète le socle 02-ML-Cours (#12455 volet 1/3) :
le classifieur génératif, jamais enseigné dans la série. Gaussian NB from
scratch (Bayes + log-vraisemblance), vérifié bit à bit contre sklearn
(0.925 partout, moyennes identiques), puis le compromis génératif-discriminatif
mesuré sur deux scénarios (Prong-B, pas un pitch) :

- Scénario A (corrélation homogène rho=0.6, hypothèse plausible) : NB +0.09
  à n=30, écart → 0.001 à n=1920 (avantage génératif = signature du petit n).
- Scénario B (corrélation en bloc rho=0.85, hypothèse fausse) : NB plafonné
  ~0.745 (biais) pendant que la logistique s'échappe à 0.8216 (écart -0.076).

2 exercices (multinomial NB, effet de la dimension) + 1 exercice de
discrimination de régime + table de décision. Ré-exécuté via papermill
(kernel python3), 20/20 cellules, 0 erreur, séquence exec 1-9, C.1/C.2/H.3 OK.

Co-Authored-By: Claude-Code <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Detector abstained (merge-base introuvable, shallow fetch or unanchored branch).

c.415 (#11873): scope = notebooks CHANGED in this PR, not the whole corpus.
See python scripts/check_markdown_claims_output.py --help for re-running locally.
Detector rationale: c.290 / c.331 / PR #11435 pathologie.

@github-actions

Copy link
Copy Markdown
Contributor

No new ASCII flowchart introductions in modified notebooks (vs merge-base). Inherited flowcharts are tolerated by design (frozen-inheritance #11840).

Detector: python scripts/notebook_tools/detect_ascii_flowchart.py <notebooks> --json
Rationale: #11962 / SW-12 cell ## 2. Architecture d'un pipeline GraphRAG (founding case, ASCII pipeline vs Mermaid flowchart LR).
Sibling scope: detect_ascii_workaround.py (#3801) targets bar charts; this organ targets flowcharts.

@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 3.3s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 2.8s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 2.6s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 3.2s
Search-1-StateSpace.ipynb ✅ SUCCESS 2.6s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 2.0s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 14.5s
GameTheory-04c-NashExistence-Python.ipynb ✅ SUCCESS 2.3s

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

@github-actions

Copy link
Copy Markdown
Contributor

MD hierarchy drift -- 88ba7e3

Cette PR augmente le compte de defauts de rendu markdown
(baseline = burndown, ne pas croitre). Nouveaux defauts :

  +1 HINT-AS-HEADING  MyIA.AI.Notebooks/GameTheory/GameTheory-04b-Lean-NashExistence.ipynb
  +1 HINT-AS-HEADING  MyIA.AI.Notebooks/GenAI/PostTraining/PT_11_grpo_qwen_rlvr_on_verifiers.ipynb
  -1 HINT-AS-HEADING  MyIA.AI.Notebooks/GameTheory/GameTheory-4b-Lean-NashExistence.ipynb  (burndown)
  -9 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/01-Foundation/01-1-OpenAI-TTS-Intro.ipynb  (burndown)
  -9 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/01-Foundation/01-2-OpenAI-Whisper-STT.ipynb  (burndown)
  -9 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/01-Foundation/01-3-Basic-Audio-Operations.ipynb  (burndown)
  -5 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/01-Foundation/01-4-Whisper-Local.ipynb  (burndown)
  -8 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-1-Chatterbox-TTS.ipynb  (burndown)
  -8 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-2-XTTS-Voice-Cloning.ipynb  (burndown)
  -12 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-3-MusicGen-Generation.ipynb  (burndown)
  -9 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-4-Demucs-Source-Separation.ipynb  (burndown)
  -4 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-5-Multi-Model-TTS-Gateway.ipynb  (burndown)
  -14 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-6-MIDI-Generation.ipynb  (burndown)
  -15 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-7-Song-Generation.ipynb  (burndown)
  -15 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-8-Expressive-TTS.ipynb  (burndown)
  -15 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/02-Advanced/02-9-AceStep-Music-Generation.ipynb  (burndown)
  -8 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/03-Orchestration/03-1-Multi-Model-Audio-Comparison.ipynb  (burndown)
  -8 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/03-Orchestration/03-2-Audio-Pipeline-Orchestration.ipynb  (burndown)
  -8 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/03-Orchestration/03-3-Realtime-Voice-API.ipynb  (burndown)
  -10 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/04-Applications/04-1-Educational-Audio-Content.ipynb  (burndown)
  -15 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/04-Applications/04-2-Transcription-Pipeline.ipynb  (burndown)
  -10 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/04-Applications/04-3-Music-Composition-Workflow.ipynb  (burndown)
  -13 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/04-Applications/04-4-Audio-Video-Sync.ipynb  (burndown)
  -15 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/04-Applications/04-5-LiveCoding-LLM-Music.ipynb  (burndown)
  -8 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/04-Applications/04-6-Audiobook-Pipeline.ipynb  (burndown)
  -12 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/Audio/04-Applications/04-7-TTS-Voice-Benchmark.ipynb  (burndown)
  -9 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/CaseStudies/Barbie-Schreck/barbie-schreck.ipynb  (burndown)
  -9 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/CaseStudies/Fort-Boyard/fort-boyard-python.ipynb  (burndown)
  -9 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/CaseStudies/Medical-Chatbot/medical_chatbot.ipynb  (burndown)
  -9 HEADING-IN-LIST  MyIA.AI.Notebooks/GenAI/PostTraining/PT_11_grpo_qwen_rlvr_on_verifiers.ipynb  (burndown)
  -13 HEADING-IN-LIST  MyIA.AI.Notebooks/Probas/DecisionTheory/PyMC/DecPyMC-3-Multi-Attribute.ipynb  (burndown)
  -19 HEADING-IN-LIST  MyIA.AI.Notebooks/Probas/DecisionTheory/PyMC/DecPyMC-6-Expert-Systems.ipynb  (burndown)
  -8 HEADING-IN-LIST  MyIA.AI.Notebooks/Probas/DecisionTheory/PyMC/DecPyMC-7-Sequential.ipynb  (burndown)
  -8 HEADING-IN-LIST  MyIA.AI.Notebooks/Probas/Infer-101.ipynb  (burndown)
  -4 HEADING-IN-LIST  MyIA.AI.Notebooks/Probas/Infer/Infer-2-Gaussian-Mixtures.ipynb  (burndown)
  -13 HEADING-IN-LIST  MyIA.AI.Notebooks/Probas/Infer/Infer-6-Debugging.ipynb  (burndown)
  -15 HEADING-IN-LIST  MyIA.AI.Notebooks/QuantConnect/ML-Training-Pipeline/hmm_alpha_research.ipynb  (burndown)
  -6 HEADING-IN-LIST  MyIA.AI.Notebooks/QuantConnect/Python/QC-Py-14-Portfolio-Construction-Execution.ipynb  (burndown)
  -6 HEADING-IN-LIST  MyIA.AI.Notebooks/QuantConnect/Python/QC-Py-18-ML-Features-Engineering.ipynb  (burndown)
  -6 HEADING-IN-LIST  MyIA.AI.Notebooks/QuantConnect/Python/QC-Py-19-ML-Supervised-Classification.ipynb  (burndown)
  -6 HEADING-IN-LIST  MyIA.AI.Notebooks/QuantConnect/Python/QC-Py-24-Autoencoders-Anomaly.ipynb  (burndown)
  -6 HEADING-IN-LIST  MyIA.AI.Notebooks/QuantConnect/Python/QC-Py-27-Production-Deployment.ipynb  (burndown)

=== drift: +2 across 2 notebook(s), 386 burned down ===

Corriger (ex. - # Indice : ... -> - **Indice :** ...) ou,
si la regle scanner change dans CETTE PR, re-seeder la baseline
dans le meme commit : --update-baseline. See #11831.

@github-actions

Copy link
Copy Markdown
Contributor

✅ No render volume delta signal (notebooks modified vs merge-base preserve >= 50% of base rendered output per MIME family).

See python scripts/notebook_tools/check_render_volume_delta.py --help for re-running locally.
Detector rationale: #11656 / #11351 pathologie (840 B remnants in 195 692 B cells = absolute detectors blind).
Why merge-base not origin/main two-dots: a branch 25+ commits behind would have the detector scan 35 notebooks the PR never touched.

@github-actions github-actions Bot added the pedagogy-density-below-threshold A modified notebook measures below the 1200 chars-of-prose-per-code-cell floor (#10479) label Aug 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ No fragmented stream outputs detected.

See python scripts/notebook_tools/check_outputs_text_fragmentation.py --help for re-running locally.
Detector rationale: c.354-L2 ★★, PR #11664.

@github-actions

Copy link
Copy Markdown
Contributor

No new degraded-mode confessions in modified notebooks (vs merge-base). Inherited confessions are tolerated by design (frozen-inheritance).

Detector: python scripts/notebook_tools/detect_degraded_mode.py <nb> --base <merge-base> --check
Rationale: #11754 / #11443 (860 KB lost while all structural gates stayed green).

@github-actions

Copy link
Copy Markdown
Contributor

Notebook PR Validation: PASS

  • Notebooks checked: 1
  • Code cells validated: 9
  • 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)

@myia-ai-01

Copy link
Copy Markdown
Collaborator

Merge apres verification firsthand de la preuve d'execution (§D).

Mesure sur 2.3b-Naive-Bayes-Generatif.ipynb a la tete de branche :

grandeur valeur
cellules 9 code, 11 markdown
execution_count 1..9 contigus
execution_count null 0
sorties d'erreur 0
motifs C.1 interdits 0
bloc metadata.papermill present

Verdict EXEC_PROVED, pas STRUCTURAL_ONLY. Les 3 cellules sans outputs sont des cellules d'import/definition — absence de sortie attendue, pas une sortie stripee. Le validateur CI concorde (Notebook PR Validation: PASS, 9 cellules code, H.1/H.3/C.1).

Le bloc metadata.papermill est present et non perime ici : c'est precisement ce qui manque aux 11 PRs de la classe #12722 que je viens de dispatcher. Rien a faire de ce cote.

B.0 : check_unaddressed_nits.py 12664 -> OK. Les 3 derniers commentaires sont tous des bots advisory (fragmentation No fragmented stream outputs, degraded-mode No new confessions, validation PASS), relus a l'instant du merge — aucune remarque humaine en attente.

Label pedagogy-density-below-threshold : advisory, non bloquant. 11 cellules markdown pour 9 de code sur un volet 1/3 qui pose le cadre generatif-vs-discriminatif — la densite se jugera sur la serie complete, pas sur le premier volet.

Grain: MED/notebook-python — lane myia-po-2024:CoursIA-2 — prev: MED/notebook-python #12659 : deux notebook-python consecutifs, autorises par G-VAR-3 des lors que la substance est genuinement distincte#12659 portait les hypotheses de la regression (statsmodels, VIF, het_white), celle-ci pose Naive Bayes generatif face a la logistique discriminative. Contenus differents, pas une serie scan-generable. Genre CONTENU, G-VAR-1 tenu.

@myia-ai-01
myia-ai-01 merged commit 5c199e5 into main Aug 24, 2026
79 of 80 checks passed
@jsboige
jsboige deleted the feature/12455-nb-generatif branch September 2, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

machine-dep-timing-delta: 0 (1 files) pedagogy-density-below-threshold A modified notebook measures below the 1200 chars-of-prose-per-code-cell floor (#10479)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants