|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | + |
| 4 | + <head> |
| 5 | + <meta charset="utf-8"> |
| 6 | + |
| 7 | + <title>Machine Learning - Javascript</title> |
| 8 | + |
| 9 | + <meta name="description" content="Machine learning in Javascript"> |
| 10 | + <meta name="author" content="Piero Savastano"> |
| 11 | + |
| 12 | + <meta name="apple-mobile-web-app-capable" content="yes"> |
| 13 | + <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> |
| 14 | + |
| 15 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"> |
| 16 | + |
| 17 | + <link rel="icon" type="image/x-icon" href="favicon.ico"> |
| 18 | + |
| 19 | + <link rel="stylesheet" href="css/reveal.css"> |
| 20 | + <link rel="stylesheet" href="css/theme/moon.css" id="theme"> |
| 21 | + <link rel="stylesheet" href="css/pieroit.css"> |
| 22 | + |
| 23 | + <!-- Code syntax highlighting --> |
| 24 | + <link rel="stylesheet" href="lib/css/zenburn.css"> |
| 25 | + |
| 26 | + <!-- Printing and PDF exports --> |
| 27 | + <script> |
| 28 | + var link = document.createElement( 'link' ); |
| 29 | + link.rel = 'stylesheet'; |
| 30 | + link.type = 'text/css'; |
| 31 | + link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css'; |
| 32 | + document.getElementsByTagName( 'head' )[0].appendChild( link ); |
| 33 | + </script> |
| 34 | + |
| 35 | + <!--[if lt IE 9]> |
| 36 | + <script src="lib/js/html5shiv.js"></script> |
| 37 | + <![endif]--> |
| 38 | + </head> |
| 39 | + |
| 40 | + <body> |
| 41 | + |
| 42 | + <div class="reveal"> |
| 43 | + |
| 44 | + <!-- Any section element inside of this container is displayed as a slide --> |
| 45 | + <div class="slides"> |
| 46 | + |
| 47 | + <!-- Intro --> |
| 48 | + <section> |
| 49 | + <h1><a href="index.html">Machine Learning</a></h1> |
| 50 | + <div class="white"> |
| 51 | + <img width="30%" src="img/logo-spark.png" /> |
| 52 | + </div> |
| 53 | + <br/> |
| 54 | + <ul> |
| 55 | + <li>MLlib overview</li> |
| 56 | + <li>XXXXXXXXXX</li> |
| 57 | + </ul> |
| 58 | + </section> |
| 59 | + |
| 60 | + <!-- Panorama --> |
| 61 | + <section> |
| 62 | + <a target="_blank" href="http://spark.apache.org/docs/latest/mllib-guide.html"> |
| 63 | + <img width="30%" src="img/spark_MLlib.png" /> |
| 64 | + </a> |
| 65 | + </section> |
| 66 | + |
| 67 | + <!-- Demo --> |
| 68 | + <section> |
| 69 | + <section> |
| 70 | + <a href="https://github.com/NaturalNode/natural"> |
| 71 | + <img width="100%" src="img/naturalJS.png" /> |
| 72 | + </a> |
| 73 | + </section> |
| 74 | + <section> |
| 75 | + <pre class="stretch"><code class="hljs" data-trim> |
| 76 | +var natural = require('natural'), |
| 77 | + classifier = new natural.BayesClassifier(); |
| 78 | + |
| 79 | + |
| 80 | +classifier.addDocument('my unit-tests failed.', 'software'); |
| 81 | +classifier.addDocument('tried the program, but it was buggy.', 'software'); |
| 82 | +classifier.addDocument('the drive has a 2TB capacity.', 'hardware'); |
| 83 | +classifier.addDocument('i need a new power supply.', 'hardware'); |
| 84 | + |
| 85 | +classifier.train(); |
| 86 | + |
| 87 | +classifier.save('classifier.json', function(err, classifier) { |
| 88 | + // the classifier is saved to the classifier.json file! |
| 89 | + |
| 90 | + natural.BayesClassifier.load('classifier.json', null, function(err, classifier) { |
| 91 | + console.log(classifier.classify('did you buy a new drive?')); |
| 92 | + }); |
| 93 | +}); |
| 94 | + </code></pre> |
| 95 | + </section> |
| 96 | + </section> |
| 97 | + |
| 98 | + <section> |
| 99 | + <section> |
| 100 | + <a href="http://cs.stanford.edu/people/karpathy/convnetjs/"> |
| 101 | + <img width="100%" src="img/convnetjs.png" /> |
| 102 | + </a> |
| 103 | + </section> |
| 104 | + <section> |
| 105 | + <div>"The Deep Learning Conspiracy"</div> |
| 106 | + <a href="http://www.kdnuggets.com/wp-content/uploads/photo.jpg"> |
| 107 | + <img width="100%" src="img/deep_learning_conspiracy.jpg" /> |
| 108 | + </a> |
| 109 | + </section> |
| 110 | + </section> |
| 111 | + |
| 112 | + <!-- Statistics libs --> |
| 113 | + <section> |
| 114 | + <a href="http://simplestatistics.org/"> |
| 115 | + <img width="100%" src="img/simplestatisticsjs.png" /> |
| 116 | + </a> |
| 117 | + </section> |
| 118 | + <section> |
| 119 | + <a href="http://jstat.github.io/"> |
| 120 | + <img width="100%" src="img/jstat.png" /> |
| 121 | + </a> |
| 122 | + </section> |
| 123 | + |
| 124 | + <section> |
| 125 | + <h2>Takeaway</h2> |
| 126 | + <ul> |
| 127 | + <li>Algorithm vs. Model</li> |
| 128 | + <li>Javascript is good to run the Model</li> |
| 129 | + </ul> |
| 130 | + </section> |
| 131 | + |
| 132 | + <!-- Example --> |
| 133 | + <section data-background="img/graph_viz.png" class="white"> |
| 134 | + <h2>Let's write a model</h2> |
| 135 | + <ul> |
| 136 | + <li>Data gathering and cleaning</li> |
| 137 | + <li>Algorithm choice</li> |
| 138 | + <li>Model training</li> |
| 139 | + <li>Recommend</li> |
| 140 | + </ul> |
| 141 | + </section> |
| 142 | + |
| 143 | + <section> |
| 144 | + <h2>Get data</h2> |
| 145 | + <div>Italian food</div> |
| 146 | + <pre><code class="hljs" data-trim> |
| 147 | +SELECT DISTINCT ?id ?label ?content WHERE { |
| 148 | + ?id a dbo:Food . |
| 149 | + ?id dbo:origin dbr:Italy . |
| 150 | + ?id dbo:abstract ?content . |
| 151 | + ?id rdfs:label ?label . |
| 152 | + |
| 153 | + FILTER(LANG(?label) = "en") |
| 154 | + FILTER(LANG(?content) = "en") |
| 155 | +} LIMIT 10000 |
| 156 | + </code></pre> |
| 157 | + <a href="http://dbpedia.org/sparql"> |
| 158 | + Run on dbPedia |
| 159 | + </a> |
| 160 | + </section> |
| 161 | + |
| 162 | + <!-- Measuring similarity between texts --> |
| 163 | + <section> |
| 164 | + <section> |
| 165 | + <h2>Algorithm</h2> |
| 166 | + <div>Jaccard/Tanimoto index</div> |
| 167 | + <img src="img/tanimoto.png" /> |
| 168 | + </section> |
| 169 | + <section> |
| 170 | + <h2>Algorithm</h2> |
| 171 | + <div>Jaccard/Tanimoto index</div> |
| 172 | + <pre><code class="hljs" data-trim> |
| 173 | +function similarity( bagA, bagB ) { |
| 174 | + |
| 175 | + var nIntersection = _.intersection( bagA, bagB).length; |
| 176 | + var nUnion = _.union( bagA, bagB ).length; |
| 177 | + |
| 178 | + return nIntersection / nUnion; |
| 179 | +}; |
| 180 | + </code></pre> |
| 181 | + </section> |
| 182 | + </section> |
| 183 | + |
| 184 | + <!-- Build similarity graph --> |
| 185 | + <section> |
| 186 | + <h2>Similarity graph</h2> |
| 187 | + <span> |
| 188 | + <img height="200px" src="img/similarity_graph.jpg" /> |
| 189 | + </span> |
| 190 | + <pre><code class="hljs" data-trim contenteditable> |
| 191 | +var similarityGraph = { |
| 192 | + "A":{ |
| 193 | + "B": 0.1, |
| 194 | + "C": 0.8, |
| 195 | + }, |
| 196 | + "B":{ |
| 197 | + "A": 0.1, |
| 198 | + "C": 0.5, |
| 199 | + }, |
| 200 | + "C":{ |
| 201 | + "A": 0.8, |
| 202 | + "B": 0.5, |
| 203 | + } |
| 204 | +}; |
| 205 | + </code></pre> |
| 206 | + </section> |
| 207 | + |
| 208 | + <!-- Demo --> |
| 209 | + <section> |
| 210 | + <img width="800px" src="img/demo.jpg" /> |
| 211 | + <div> |
| 212 | + <a href="https://github.com/pieroit/machine-learning-open-course/tree/gh-pages/nodejs-example">Show me the code!</a> |
| 213 | + </div> |
| 214 | + </section> |
| 215 | + |
| 216 | + </div> |
| 217 | + |
| 218 | + <script src="lib/js/head.min.js"></script> |
| 219 | + <script src="js/reveal.js"></script> |
| 220 | + |
| 221 | + <script> |
| 222 | + |
| 223 | + // Full list of configuration options available at: |
| 224 | + // https://github.com/hakimel/reveal.js#configuration |
| 225 | + Reveal.initialize({ |
| 226 | + controls: true, |
| 227 | + progress: true, |
| 228 | + history: true, |
| 229 | + center: true, |
| 230 | + |
| 231 | + transition: 'slide', // none/fade/slide/convex/concave/zoom |
| 232 | + |
| 233 | + // Optional reveal.js plugins |
| 234 | + dependencies: [ |
| 235 | + { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, |
| 236 | + { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
| 237 | + { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
| 238 | + { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, |
| 239 | + { src: 'plugin/zoom-js/zoom.js', async: true }, |
| 240 | + { src: 'plugin/notes/notes.js', async: true } |
| 241 | + ] |
| 242 | + }); |
| 243 | + |
| 244 | + </script> |
| 245 | + |
| 246 | + </body> |
| 247 | +</html> |
0 commit comments