|
| 1 | +{ |
| 2 | + "title": "Bayesian Text Classification", |
| 3 | + "description": "In this coding challenge, I struggle my way through implementing a Naive Bayes text classifier in JavaScript using p5.js. I explain Bayes' theorem, demonstrate word frequency analysis, implement Laplacian smoothing, and build a working sentiment classifier that runs entirely in the browser.", |
| 4 | + "videoNumber": "187", |
| 5 | + "videoId": "g3-PXyF8U70", |
| 6 | + "date": "2025εΉ΄10ζ11ζ₯", |
| 7 | + "nebulaSlug": "codingtrain-coding-challenge-187-bayes-classifier", |
| 8 | + "languages": ["JavaScript", "p5.js"], |
| 9 | + "topics": [ |
| 10 | + "Bayes theorem", |
| 11 | + "text classification", |
| 12 | + "naive Bayes", |
| 13 | + "sentiment analysis", |
| 14 | + "natural language processing", |
| 15 | + "machine learning", |
| 16 | + "word frequency", |
| 17 | + "Laplacian smoothing" |
| 18 | + ], |
| 19 | + "canContribute": true, |
| 20 | + "relatedChallenges": ["40-word-counter", "42-markov-chain-name-generator"], |
| 21 | + "timestamps": [ |
| 22 | + { "time": "0:00:00", "title": "Hello!" }, |
| 23 | + { "time": "0:03:34", "title": "Explaining Bayes' Theorem" }, |
| 24 | + { "time": "0:12:07", "title": "What is Naive Bayes?" }, |
| 25 | + { "time": "0:13:49", "title": "Setting up the Classifier in p5.js" }, |
| 26 | + { "time": "0:15:41", "title": "Coding the train() function " }, |
| 27 | + { "time": "0:22:14", "title": "Coding the classify() Function" }, |
| 28 | + { "time": "0:24:45", "title": "Revising the train() function" }, |
| 29 | + { "time": "0:29:06", "title": "Implementing Probability Calculations" }, |
| 30 | + { "time": "0:33:24", "title": "Laplacian (Additive) Smoothing" }, |
| 31 | + { "time": "0:42:21", "title": "Ignoring the enominator (Normalization)" }, |
| 32 | + { "time": "0:45:36", "title": "Quick User Interface" }, |
| 33 | + { "time": "0:49:42", "title": "Final thoughts and next steps." } |
| 34 | + ], |
| 35 | + "codeExamples": [ |
| 36 | + { |
| 37 | + "title": "Text Classifier - Initial Version", |
| 38 | + "description": "Raw (but corrected) version in p5.js web editor.", |
| 39 | + "image": "classify.png", |
| 40 | + "urls": { |
| 41 | + "p5": "https://editor.p5js.org/codingtrain/sketches/RZ8a1z4DN" |
| 42 | + } |
| 43 | + }, |
| 44 | + { |
| 45 | + "title": "Text Classifier - Refactored Version", |
| 46 | + "image": "classify.png", |
| 47 | + "description": "Refactored version with better structure and comments.", |
| 48 | + "urls": { |
| 49 | + "p5": "https://editor.p5js.org/codingtrain/sketches/P3ngrAANX", |
| 50 | + "other": "https://github.com/Programming-from-A-to-Z/bayes-classifier-js" |
| 51 | + } |
| 52 | + }, |
| 53 | + { |
| 54 | + "title": "Text Classifier - File Loading Version", |
| 55 | + "description": "Version that loads training data from three novels (romance, horror, sci-fi).", |
| 56 | + "image": "classifyfiles.png", |
| 57 | + "urls": { |
| 58 | + "p5": "https://editor.p5js.org/codingtrain/sketches/WowR2Q9xg" |
| 59 | + } |
| 60 | + } |
| 61 | + ], |
| 62 | + "groupLinks": [ |
| 63 | + { |
| 64 | + "title": "References", |
| 65 | + "links": [ |
| 66 | + { |
| 67 | + "icon": "π", |
| 68 | + "title": "Naive Bayes Classifier", |
| 69 | + "url": "https://en.wikipedia.org/wiki/Naive_Bayes_classifier", |
| 70 | + "description": "Wikipedia article explaining naive Bayes classification algorithms." |
| 71 | + }, |
| 72 | + { |
| 73 | + "icon": "π", |
| 74 | + "title": "Laplacian Smoothing", |
| 75 | + "url": "https://en.wikipedia.org/wiki/Additive_smoothing", |
| 76 | + "description": "Wikipedia article about additive (Laplacian) smoothing technique." |
| 77 | + } |
| 78 | + ] |
| 79 | + }, |
| 80 | + { |
| 81 | + "title": "Videos", |
| 82 | + "links": [ |
| 83 | + { |
| 84 | + "icon": "π", |
| 85 | + "title": "Word Counting", |
| 86 | + "url": "/challenges/40-word-counter", |
| 87 | + "description": "Video series on text analysis and word counting fundamentals." |
| 88 | + }, |
| 89 | + { |
| 90 | + "icon": "π", |
| 91 | + "title": "Regular Expressions", |
| 92 | + "url": "https://youtu.be/7DG3kCDx53c?list=PLRqwX-V7Uu6YEypLuls7iidwHMdCM6o2w", |
| 93 | + "description": "Video series covering regular expressions for text processing." |
| 94 | + }, |
| 95 | + { |
| 96 | + "icon": "πΊ", |
| 97 | + "title": "Bayes theorem, the geometry of changing beliefs", |
| 98 | + "url": "https://youtu.be/HZGCoVF3YvM", |
| 99 | + "description": "Visual explanation of Bayes' theorem with geometric visualization from 3Blue1Brown." |
| 100 | + }, |
| 101 | + { |
| 102 | + "icon": "π", |
| 103 | + "title": "p5.js 2.0: async and await", |
| 104 | + "url": "/tracks/p5js-2.0/p5js-2.0/async-await", |
| 105 | + "description": "Asynchronous programming in p5.js using async and await." |
| 106 | + } |
| 107 | + ] |
| 108 | + }, |
| 109 | + { |
| 110 | + "title": "Live Stream Archives", |
| 111 | + "links": [ |
| 112 | + { |
| 113 | + "icon": "π΄", |
| 114 | + "title": "Full Live Stream", |
| 115 | + "url": "https://youtube.com/live/TsBDm0P0qaA", |
| 116 | + "description": "Complete unedited live stream showing the development process with all mistakes and problem-solving." |
| 117 | + } |
| 118 | + ] |
| 119 | + } |
| 120 | + ], |
| 121 | + "credits": [ |
| 122 | + { "title": "Editing", "name": "Mathieu Blanchette" }, |
| 123 | + { "title": "Animations", "name": "Jason Heglund" } |
| 124 | + ] |
| 125 | +} |
0 commit comments