├── .gitignore
├── README.md
├── images
├── adafruit.png
├── aiml.png
├── algomap.jpg
├── ann_350.png
├── brain.png
├── braincraft.png
├── braincraft_movie.gif
├── braincraft_movie.mp4
├── braincraft_play.png
├── brilliant.png
├── deepracer.jpg
├── edge.jpg
├── facenumbers.png
├── google.png
├── hal.png
├── hardware.png
├── heartless.jpg
├── intel.jpg
├── knn.png
├── lobe.png
├── logic.png
├── mlmap.png
├── model1.png
├── model2.png
├── network.png
├── nn.png
├── nnchart.png
├── playground.png
├── pose.png
├── pythagorean.png
├── python.png
├── retriever.png
├── runwayml.png
├── teachablemachine.png
├── teleport.png
├── unity.png
├── unity_nn.png
├── unitydemo.png
├── unityterminal.png
├── weights.png
├── weights_activation_function.png
└── wekinator.png
└── snippets
├── .DS_Store
├── camera.md
├── csv.md
├── extractfeatures
├── app.js
├── features.png
├── index.html
├── readme.md
└── style.css
├── introduction.md
├── layers.md
├── python.md
├── reactnative
├── README.md
└── tensorflowjs.md
├── speech.md
├── unity.md
└── uploadimage.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | .vscode
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Javascript Machine Learning
2 |
3 | This repository maintains a reading list of Machine Learning technologies, algorithms and API's focused on javascript.
4 |
5 | ### Why Javascript?
6 |
7 | - Can run on any web client, the end user doesn't have to install anything.
8 | - Easy integration with device sensors such as camera, microphone, gyroscope, light sensor, etc.
9 | - End user does not have to send privacy-sensitive data to a server.
10 | - Easy integration with user interface and interactive elements.
11 | - Easy install process for developer, less sensitive to computer setup issues, python setup issues, version conflicts.
12 | - Convert your AI code to a web server with one line of code.
13 | - Can still use models trained in Python.
14 | - Training uses the same underlying C / GPU capabilities of your computer.
15 |
16 | > *Python is used in the science community, so there are much more python libraries for math and computer science subjects available. Most AI tutorials will use python.*
17 |
18 |
19 |
20 | # Contents
21 |
22 | - [Getting started](#gettingstarted)
23 | - [Neural networks](#neuralnetworks)
24 | - [Algorithms](#algorithms)
25 | - [Language models](#languagemodels)
26 | - [Image recognition](#images)
27 | - [Speech](#speech)
28 | - [Loading and evaluating data](#loadingdata)
29 | - [Datasets](#datasets)
30 | - [Community](#community)
31 | - [Cloud GPU](#cloud)
32 | - [Random links](#examples)
33 |
34 |
35 |
36 |
37 |
38 | 
39 |
40 | ## Getting started with Machine Learning
41 |
42 | - [🔥 Elements of AI part 1](https://course.elementsofai.com) and [part 2](https://buildingai.elementsofai.com)
43 | - [De Nederlandse AI Cursus](https://www.ai-cursus.nl)
44 | - [Brilliant.org - tutorial app with daily questions](https://brilliant.org/courses/artificial-neural-networks/)
45 | - [A visual introduction to Machine Learning](http://www.r2d3.us/visual-intro-to-machine-learning-part-1/)
46 |
47 |
48 |
49 | ## Neural Networks in Javascript
50 |
51 | - [ML5](https://learn.ml5js.org/#/reference/neural-network)
52 | - [BrainJS](https://brain.js.org/#/getting-started)
53 | - [TensorflowJS](https://www.tensorflow.org/js).
54 | - [Build a Neural Network in JS without any libraries](https://dev.to/grahamthedev/a-noob-learns-ai-my-first-neural-networkin-vanilla-jswith-no-libraries-1f92)
55 | - [Get started with ML5 neural networks](https://learn.ml5js.org/#/reference/neural-network) and add [hidden layers](./snippets/layers.md)
56 | - [Building your first Neural Network in Tensorflow JS](https://towardsdatascience.com/build-a-simple-neural-network-with-tensorflow-js-d434a30fcb8)
57 | - [Regression with Tensorflow](https://codelabs.developers.google.com/codelabs/tfjs-training-regression/index.html)
58 | - [Getting started with TensorflowJS](https://curiousily.com/posts/getting-started-with-tensorflow-js/)
59 | - [CodePen](https://codepen.io/topic/tensorflow/templates), [Traversy](https://youtu.be/tZt6gRlRcgk) and [W3Schools](https://www.w3schools.com/ai/ai_tensorflow_intro.asp) tensorflow tutorials.
60 | - [Build rock-paper-scissors with Reinforcement Learning](https://towardsdatascience.com/a-beginners-guide-to-reinforcement-learning-using-rock-paper-scissors-and-tensorflow-js-37d42b6197b5) and [github](https://github.com/sachag678/freeCodeCamp)
61 | - [Reinforcement Learning library](https://epic-darwin-f8b517.netlify.app) with [github](https://github.com/ttumiel/gym.js/) and [game tutorial](https://medium.com/@pierrerouhard/reinforcement-learning-in-the-browser-an-introduction-to-tensorflow-js-9a02b143c099)
62 |
63 |
64 |
65 | ## Algorithms in Javascript
66 |
67 | - [A visual tour of machine learning algorithms](https://machinelearningmastery.com/a-tour-of-machine-learning-algorithms/)
68 | - [Machine Learning algorithms for newbies](https://towardsdatascience.com/a-tour-of-the-top-10-algorithms-for-machine-learning-newbies-dde4edffae11)
69 | - [Math concepts for Programmers](https://www.youtube.com/watch?v=2SpuBqvNjHI)
70 | - [K-Nearest Neighbour](https://github.com/NathanEpstein/KNear) and an [explanation of writing your own KNN in Javascript](https://burakkanber.com/blog/machine-learning-in-js-k-nearest-neighbor-part-1/)
71 | - [K-Means](https://miguelmota.com/blog/k-means-clustering-in-javascript/)
72 | - [Decision Tree, Random Forest](https://github.com/lagodiuk/decision-tree-js) and [Regression Tree](https://winkjs.org/wink-regression-tree/)
73 | - [Movie Recommender System in Javascript](https://github.com/javascript-machine-learning/movielens-recommender-system-javascript) and a [quick and dirty tutorial on building your own recommender system](https://dev.to/jimatjibba/build-a-content-based-recommendation-engine-in-js-2lpi)
74 | - [Create a self-driving car with a evolving genetic algorithm](https://github.com/gniziemazity/Self-driving-car) and another example on [dev.to](https://dev.to/trekhleb/self-parking-car-in-500-lines-of-code-58ea)
75 |
76 |
77 |
78 | ## Language models and API's for Javascript
79 |
80 | - [LangChain LLM library](https://js.langchain.com/docs/get_started/introduction) gives you a unified workflow for working with all kinds of different language models, providers, datastores, etc.
81 | - [OpenAI API](https://platform.openai.com/docs/introduction)
82 | - [Azure OpenAI library](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/openai/openai) and [docs](https://learn.microsoft.com/en-gb/javascript/api/%40azure/openai/), you can use this if you have a Microsoft Azure key instead of a OpenAI key.
83 | - [LLama API](https://www.llama-api.com), [Mistral API](https://docs.mistral.ai), [Claude API](https://support.anthropic.com/en/collections/5370014-claude-api). These models have API's so you don't have to install anything.
84 | - Use [OLLama](https://ollama.ai) to run language models locally, talk to the LLM with the built-in webserver.
85 | - [🐐 Geitje](https://goingdutch.ai/en/posts/introducing-geitje/) is a Dutch large language model.
86 | - [Read more about language processing](https://towardsdatascience.com/natural-language-processing-from-basics-to-using-rnn-and-lstm-ef6779e4ae66), [Natural Language Processing in Javascript](http://naturalnode.github.io/natural/), [Create your own mini-LLM in Paperspace](https://blog.paperspace.com/training-an-lstm-and-using-the-model-in-ml5-js/)
87 | - [What are word vectors?](https://gist.github.com/aparrish/2f562e3737544cf29aaf1af30362f469) and [📺 Understanding Word2Vec](https://youtu.be/MOo9iJ8RYWM)
88 |
89 |
90 |
91 | ## Image recognition
92 |
93 | - [Google MediaPipe for pose, object, image, segment detection](https://mediapipe-studio.webapps.google.com/home)
94 | - [ML5 Image Classifier](https://learn.ml5js.org/#/reference/image-classifier) and [Object Detection](https://learn.ml5js.org/#/reference/object-detector) in ML5.js
95 | - [Create teachable machine from scratch with TensorFlowJS](https://codelabs.developers.google.com/tensorflowjs-transfer-learning-teachable-machine#16)
96 | - [Use KNN to classify poses with ML5](https://learn.ml5js.org/#/reference/knn-classifier)
97 | - [Recognise handwriting in Javascript](https://github.com/cazala/mnist)
98 | - [Face-JS, a library to track facial expressions](https://justadudewhohacks.github.io/face-api.js/docs/index.html)
99 | - [Hand Tracking JS](https://victordibia.github.io/handtrack.js/)
100 | - [Image recognition with your own images](./snippets/extractfeatures) and [Feature Extraction documentation](https://ml5js.org/reference/api-FeatureExtractor/)
101 |
102 |
103 |
104 | ## Speech
105 |
106 | - [Generate voices with Elevenlabs](https://elevenlabs.io)
107 | - [Listen to human speech in the browser](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API), and a [Simple demo of listening and speaking with javascript](https://github.com/mdn/web-speech-api)
108 | - [OpenAI Whisper](https://platform.openai.com/docs/guides/speech-to-text)
109 | - [Recognise sound using the browser, microphone, and TensorflowJS](https://dev.to/devdevcharlie/acoustic-activity-recognition-in-javascript-2go4)
110 | - [Code example web speech](./snippets/speech.md) and [webcam](./snippets/camera.md)
111 |
112 |
113 |
114 | ## Loading and evaluating data
115 |
116 | - [Load CSV data in javascript with Papa Parse](https://www.papaparse.com), and [code example to load and filter data](./snippets/csv.md)
117 | - Visualise data with [D3.js](https://d3js.org), [VEGA](https://vega.github.io/vega/), [ChartJS](https://www.chartjs.org) or [PlotlyJS](https://plotly.com/javascript/)
118 | - [Code example for drawing Scatterplot from a CSV file](./snippets/scatterplot.md)
119 | - [Code example for data normalisation](./snippets/normalise.md)
120 | - [Visualise Tensorflow with TFVis](https://js.tensorflow.org/api_vis/1.4.3/)
121 | - [Manipulate large amounts of data with Danfo.js](https://danfo.jsdata.org)
122 |
123 |
124 |
125 | ## Datasets
126 |
127 | - [Google Dataset Search](https://datasetsearch.research.google.com)
128 | - [HuggingFace Datasets](https://huggingface.co/datasets?sort=trending)
129 | - [Kaggle Datasets](https://www.kaggle.com/datasets/)
130 | - [Customer Churn](https://www.kaggle.com/datasets/blastchar/telco-customer-churn)
131 | - [Mobile Phone Prices](https://www.kaggle.com/datasets/pratikgarai/mobile-phone-specifications-and-prices)
132 | - [UFO sightings](https://www.kaggle.com/NUFORC/ufo-sightings)
133 | - [Football results](https://www.kaggle.com/martj42/international-football-results-from-1872-to-2017)
134 | - [Speed Dating](https://www.kaggle.com/datasets/annavictoria/speed-dating-experiment) and [Marriage](https://www.kaggle.com/aagghh/divorcemarriage-dataset-with-birth-dates)
135 | - [Spam detection](https://www.kaggle.com/datasets/veleon/ham-and-spam-dataset)
136 | - [Socrata Open Data search](https://dev.socrata.com/data/)
137 | - [UCI Machine Learning Repository](https://archive-beta.ics.uci.edu)
138 | - [Open Images Dataset](https://storage.googleapis.com/openimages/web/index.html)
139 | - [MovieLens - data on 45.000 movies by 270.000 users](https://www.kaggle.com/rounakbanik/the-movies-dataset/data)
140 | - [🐱 440 Cat meows in different contexts](https://zenodo.org/record/4008297#.YNGgey8RppQ) and [Cats per square kilometer](https://data.gov.uk/dataset/9d475e06-3885-4a90-b8c0-77fea13f92e6/cats-per-square-kilometre)
141 | - [Speech Audio dataset](https://keithito.com/LJ-Speech-Dataset/)
142 | - [QuickDraw - Doodles dataset](https://github.com/googlecreativelab/quickdraw-dataset/)
143 | - [COCO - Common Objects in Context](https://cocodataset.org/#home)
144 | - [Rotterdam Open Data](http://rotterdamopendata.nl/dataset) en [Rotterdam 3D data](https://www.3drotterdam.nl/#/)
145 | - [Netherlands Open OV Data](https://www.openov.nl)
146 | - [Traffic data "persons in urban traffic scenes" TU Delft](https://eurocity-dataset.tudelft.nl)
147 | - [Dataregister van de Nederlandse Overheid](https://data.overheid.nl)
148 | - [Cars data with 20.000 images of 190 types of car](https://ai.stanford.edu/~jkrause/cars/car_dataset.html)
149 | - [Celebrity faces dataset on Kaggle](https://www.kaggle.com/jessicali9530/celeba-dataset) and [source](https://mmlab.ie.cuhk.edu.hk/projects/CelebA.html)
150 | - [International Football Results from 1872 to 2017](https://www.kaggle.com/martj42/international-football-results-from-1872-to-2017)
151 | - [Luchtmeetnet luchtvervuiling CSV data](https://data.rivm.nl/data/luchtmeetnet/Actueel-jaar/)
152 | - [Daily stock prices](https://www.alphavantage.co/documentation/)
153 |
154 |
155 |
156 | ## Community
157 |
158 | - [AI Stackoverflow](https://ai.stackexchange.com)
159 | - [Kaggle - Machine Learning challenges](https://www.kaggle.com)
160 | - [Welcome.ai Instagram](https://www.instagram.com/welcome.ai/)
161 | - [AI x Design Community](https://www.aixdesign.co), [Instagram](https://www.instagram.com/aixdesign.community/) and [Resources Reading List](http://bit.ly/aixd-library)
162 | - [Rotterdam AI Meetup](https://www.meetup.com/data-science-rdm/events/)
163 |
164 |
165 |
166 | ## Cloud GPU
167 |
168 | Cloud GPU enables you to train models with large amounts of data on professional infrastructure.
169 |
170 | - [Huggingface Spaces](https://huggingface.co/spaces)
171 | - [Google Vertex AI](https://cloud.google.com/vertex-ai)
172 | - [Google Colab](https://colab.research.google.com)
173 | - [PaperSpace](https://blog.paperspace.com/)
174 | - [Lambda Labs](https://lambdalabs.com/service/gpu-cloud)
175 |
176 |
177 |
178 | ## Hosting
179 |
180 | To host a `node.js` project, the best option is to create a [serverless](https://www.learnwithjason.dev/blog/serverless-functions/overview/) app. There are several providers that offer free *node* or *serverless* hosting options:
181 |
182 | - vercel.com
183 | - netlify.com
184 | - deno.com
185 | - amazon serverless
186 | - huggingface spaces
187 | - codesandbox.com
188 | - github codespaces
189 | - stackblitz.com
190 |
191 |
192 |
193 | ## Random links
194 |
195 | A collection of interesting links, tools and tutorials
196 |
197 | 
198 |
199 | - [Quick AI Introduction with javascript code examples](./snippets/introduction.md)
200 | - [Generate images with the Dall-e API](https://openai.com/blog/dall-e-api-now-available-in-public-beta)
201 | - [Tensorflow Playground](https://playground.tensorflow.org)
202 | - [React Native AI code snippets](./snippets/reactnative/)
203 | - [Visualise how a Neural Network recognises numbers](https://www.cs.cmu.edu/~aharley/vis/conv/flat.html)
204 | - [📺 Build a security camera with TensorflowJS and React](https://www.youtube.com/watch?v=7QBYX65t7Mw)
205 | - [Integrating TensorflowJS into your User Interface with Parcel](https://medium.com/codingthesmartway-com-blog/tensorflow-js-crash-course-machine-learning-for-the-web-getting-started-50694a575238)
206 | - [📺 Coding a single neuron (perceptron) in Javascript](https://youtu.be/o98qlvrcqiU) and the [result](https://beta.observablehq.com/@mpj/neural-network-from-scratch-part-1)
207 | - [Use BrainJS to get started with a simple neural network](https://brain.js.org/#/getting-started) or watch the [📺 video tutorial](https://www.youtube.com/watch?v=RVMHhtTqUxc)
208 | - [Perceptron (single neuron) code snippet](https://gist.github.com/primaryobjects/dfb8927f9f0ca21b6a24647168cead41)
209 | - [Creating a Recommender System in Javascript](https://github.com/javascript-machine-learning/movielens-recommender-system-javascript)
210 | - [😱 hacking a model to make a wrong prediction with Adversarial.js](https://kennysong.github.io/adversarial.js/)
211 | - [Predict your location in your home using the strength of your wifi signal](https://dev.to/devdevcharlie/predicting-indoor-location-using-machine-learning-and-wifi-information-m78)
212 | - [Using a Javascript Perceptron to classify dangerous snakes](https://github.com/elyx0/rosenblattperceptronjs)
213 | - [Classify an image on Codepen in 5 lines of Javascript](https://codepen.io/eerk/pen/JmKQLw)
214 | - [Neural Drum Machine](https://codepen.io/teropa/pen/JLjXGK) and [Voice-based beatbox](https://codepen.io/naotokui/pen/NBzJMW) created with [MagentaJS](https://magenta.tensorflow.org)
215 | - [Evolving Genetic Algorithm with Flappy Bird](https://github.com/ssusnic/Machine-Learning-Flappy-Bird)
216 | - [Google AI experiments](https://experiments.withgoogle.com/ai)
217 | - [Watch a perceptron learn](https://kokodoko.github.io/perceptron/)
218 | - [Synaptic JS Neural Networks](http://caza.la/synaptic/) and [Tutorial](https://medium.freecodecamp.org/how-to-create-a-neural-network-in-javascript-in-only-30-lines-of-code-343dafc50d49)
219 | - [Control a ThreeJS game with Teachable Machine](https://github.com/charliegerard/whoosh)
220 | - [Silence of the Fans - running TensorflowJS on Google Colab](https://dev.to/obenjiro/silence-of-the-fans-part-1-javascript-quickstart-5f3m) - and [code example](bit.ly/colabjs)
221 | - [Using AutoEncoders with TensorflowJS tutorial](https://douglasduhaime.com/posts/visualizing-latent-spaces.html)
222 | - [Figment uses an intuitive UI to use AI tools without coding](https://figmentapp.com)
223 | - [Hogeschool Rotterdam Datalab: Rob van der Willigen's Blog about AI](https://robfvdw.medium.com)
224 | - Google API's for [Translate](http://cloud.google.com/translate/), [Vision](http://cloud.google.com/vision/), [Speech](http://cloud.google.com/speech/) and [Language Processing](http://cloud.google.com/natural-language/)
225 | - [Microsoft Azure Machine Learning APIs](https://gallery.azure.ai/machineLearningAPIs)
226 | - [Teachable Machine](https://teachablemachine.withgoogle.com) and [Lobe.AI](https://lobe.ai) can export a model and all necessary code for your website.
227 | - [Cognimates: An AI education platform for building games, programming robots & training AI models](http://cognimates.me/home/)
228 | - [Obviously.ai](https://www.obviously.ai) can train a model with CSV data right in the browser.
229 | - Check the [Hardware, Python and Games](./snippets/python.md) reading list.
230 |
231 | ### Disclaimer
232 |
233 | Since the field of AI is evolving so rapidly, some links may be outdated. This list is maintained by [Erik Katerborg](https://kokodoko.github.io).
234 |
235 | >*Last updated: 22 january 2024.*
236 |
237 |
238 |
239 | 
240 |
241 | [https://xkcd.com/1925/](https://xkcd.com/1925/)
--------------------------------------------------------------------------------
/images/adafruit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/adafruit.png
--------------------------------------------------------------------------------
/images/aiml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/aiml.png
--------------------------------------------------------------------------------
/images/algomap.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/algomap.jpg
--------------------------------------------------------------------------------
/images/ann_350.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/ann_350.png
--------------------------------------------------------------------------------
/images/brain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/brain.png
--------------------------------------------------------------------------------
/images/braincraft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/braincraft.png
--------------------------------------------------------------------------------
/images/braincraft_movie.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/braincraft_movie.gif
--------------------------------------------------------------------------------
/images/braincraft_movie.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/braincraft_movie.mp4
--------------------------------------------------------------------------------
/images/braincraft_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/braincraft_play.png
--------------------------------------------------------------------------------
/images/brilliant.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/brilliant.png
--------------------------------------------------------------------------------
/images/deepracer.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/deepracer.jpg
--------------------------------------------------------------------------------
/images/edge.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/edge.jpg
--------------------------------------------------------------------------------
/images/facenumbers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/facenumbers.png
--------------------------------------------------------------------------------
/images/google.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/google.png
--------------------------------------------------------------------------------
/images/hal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/hal.png
--------------------------------------------------------------------------------
/images/hardware.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/hardware.png
--------------------------------------------------------------------------------
/images/heartless.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/heartless.jpg
--------------------------------------------------------------------------------
/images/intel.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/intel.jpg
--------------------------------------------------------------------------------
/images/knn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/knn.png
--------------------------------------------------------------------------------
/images/lobe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/lobe.png
--------------------------------------------------------------------------------
/images/logic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/logic.png
--------------------------------------------------------------------------------
/images/mlmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/mlmap.png
--------------------------------------------------------------------------------
/images/model1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/model1.png
--------------------------------------------------------------------------------
/images/model2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/model2.png
--------------------------------------------------------------------------------
/images/network.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/network.png
--------------------------------------------------------------------------------
/images/nn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/nn.png
--------------------------------------------------------------------------------
/images/nnchart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/nnchart.png
--------------------------------------------------------------------------------
/images/playground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/playground.png
--------------------------------------------------------------------------------
/images/pose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/pose.png
--------------------------------------------------------------------------------
/images/pythagorean.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/pythagorean.png
--------------------------------------------------------------------------------
/images/python.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/python.png
--------------------------------------------------------------------------------
/images/retriever.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/retriever.png
--------------------------------------------------------------------------------
/images/runwayml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/runwayml.png
--------------------------------------------------------------------------------
/images/teachablemachine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/teachablemachine.png
--------------------------------------------------------------------------------
/images/teleport.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/teleport.png
--------------------------------------------------------------------------------
/images/unity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/unity.png
--------------------------------------------------------------------------------
/images/unity_nn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/unity_nn.png
--------------------------------------------------------------------------------
/images/unitydemo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/unitydemo.png
--------------------------------------------------------------------------------
/images/unityterminal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/unityterminal.png
--------------------------------------------------------------------------------
/images/weights.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/weights.png
--------------------------------------------------------------------------------
/images/weights_activation_function.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/weights_activation_function.png
--------------------------------------------------------------------------------
/images/wekinator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/images/wekinator.png
--------------------------------------------------------------------------------
/snippets/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/snippets/.DS_Store
--------------------------------------------------------------------------------
/snippets/camera.md:
--------------------------------------------------------------------------------
1 | In dit voorbeeld halen we de input (stream) van de webcam op en laden deze in een video element.
2 |
3 | In de HTML plaats je een video element
4 |
5 | ```html
6 |
7 | ```
8 |
9 | Met het attribuut `autoplay` zorg je ervoor dat het videobeeld direct zal afspelen als de stream aan het element is toegekend.
10 |
11 | Vanuit javascript haal je eerst de webcam feed op en deze ken je toe aan het video element
12 |
13 | ```javascript
14 | if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
15 | navigator.mediaDevices.getUserMedia({ video: true }).then(function (stream) {
16 | video.srcObject = stream;
17 | video.onloadedmetadata = () => {
18 | video.play();
19 | };
20 | });
21 | }
22 | ```
23 |
24 | Met de functie `getUserMedia()` wordt er aan de bezoeker toestemming gevraagd om de media input te gebruiken. Hier kunnen verschillende [opties](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters) aan meegegeven worden.
25 |
--------------------------------------------------------------------------------
/snippets/csv.md:
--------------------------------------------------------------------------------
1 | # Data laden
2 |
3 | - CSV files
4 | - JSON files
5 | - Data filteren
6 | - Training data en test data
7 |
8 |
9 |
10 |
11 |
12 | ## CSV files
13 |
14 | Voeg de Papa Parse library toe aan je HTML
15 |
16 | ```HTML
17 |
18 | ```
19 | of als je met modules werkt:
20 | ```bash
21 | npm install papaparse
22 | import Papa from './PapaParse/papaparse';
23 | ```
24 |
25 | ## Javascript
26 |
27 | Download eerst een CSV file, bijvoorbeeld de [overlevenden van de Titanic](https://www.kaggle.com/c/titanic/data?select=train.csv).
28 |
29 | ```javascript
30 | function loadData(){
31 | Papa.parse("./data/titanic_survivors.csv", {
32 | download:true,
33 | header:true,
34 | dynamicTyping:true,
35 | complete: results => checkData(results.data)
36 | })
37 | }
38 |
39 | function checkData(data) {
40 | console.table(data)
41 | }
42 | ```
43 | [Papa Parse Documentatie](https://www.papaparse.com)
44 |
45 |
46 |
47 |
48 |
49 | ## JSON files
50 |
51 | Data in JSON formaat kan je ophalen met `fetch`. Hier gebruiken we `carsData.json` van google.
52 |
53 | ```javascript
54 | async function getData() {
55 | const response = await fetch('https://storage.googleapis.com/tfjs-tutorials/carsData.json')
56 | const json = await response.json()
57 | checkData(json)
58 | }
59 |
60 | function checkData(data) {
61 | console.log(data)
62 | }
63 | ```
64 |
65 |
66 |
67 |
68 |
69 | ## Data filteren
70 |
71 | Met [map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) kan je specifieke kolommen uit een dataset halen.
72 |
73 | ```javascript
74 | const selectedColumns = data.map(car => ({
75 | mpg: car.mpg,
76 | horsepower: car.horsepower,
77 | }))
78 | ```
79 |
80 | Met [filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) kan je checken of er geen ongeldige waarden in de data staan. Hier staan twee voorbeelden van filteren op `null` of op waarden die geen `number` zijn.
81 |
82 | ```javascript
83 | // check of waarden niet leeg zijn
84 | const cleanData = data.filter(car => (
85 | car.mpg != null &&
86 | car.horsepower != null
87 | ))
88 |
89 | // check of waarden een nummer zijn
90 | const cleanData = data.filter(car => (
91 | !isNaN(car.mpg) &&
92 | !isNaN(car.horsepower)
93 | ))
94 | ```
95 | Je kan `map()` en `filter()` aan elkaar plakken, dat ziet er bv. zo uit:
96 |
97 | ```javascript
98 | const cleanData = data
99 | .map(day => ({
100 | MinTemp: day.MinTemp,
101 | MaxTemp: day.MaxTemp
102 | }))
103 | .filter(day =>
104 | typeof day.MinTemp === "number" &&
105 | typeof day.MaxTemp === "number"
106 | )
107 | ```
108 |
109 |
110 |
111 |
112 |
113 | ## Training en test data
114 |
115 | Met `slice` kunnen we data opsplitsen in trainingdata en testdata. In dit geval is 80% van de data trainingdata en 20% is testdata.
116 |
117 | ```javascript
118 | let trainData = data.slice(0, Math.floor(data.length * 0.8))
119 | let testData = data.slice(Math.floor(data.length * 0.8) + 1)
120 | ```
121 |
122 | > ⚠️ Om te voorkomen dat je data *gesorteerd* is op bv. het label moet je je array shufflen **voordat** je splitst op traindata en testdata.
123 |
124 | ```javascript
125 | function shuffleArray(arr) {
126 | arr.sort(() => (Math.random() - 0.5))
127 | }
128 | ```
129 |
130 |
131 |
132 |
133 |
134 | ## Links
135 |
136 | - [Array map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
137 | - [Array filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
138 |
--------------------------------------------------------------------------------
/snippets/extractfeatures/app.js:
--------------------------------------------------------------------------------
1 | const video = document.getElementById('webcam')
2 | const featureExtractor = ml5.featureExtractor('MobileNet', modelLoaded)
3 | const label = document.getElementById("label")
4 | let classifier
5 |
6 | const nomaskbtn = document.querySelector("#nomask")
7 | const maskbtn = document.querySelector("#mask")
8 | const trainbtn = document.querySelector("#train")
9 |
10 | nomaskbtn.addEventListener("click", () => addNoMask())
11 | maskbtn.addEventListener("click", () => addMask())
12 | trainbtn.addEventListener("click", () => train())
13 |
14 | if (navigator.mediaDevices.getUserMedia) {
15 | navigator.mediaDevices.getUserMedia({ video: true })
16 | .then((stream) => {
17 | video.srcObject = stream
18 | })
19 | .catch((err) => {
20 | console.log("Something went wrong!");
21 | });
22 | }
23 |
24 | function modelLoaded(){
25 | console.log("The mobileNet model is loaded!")
26 | classifier = featureExtractor.classification(video, videoReady)
27 | }
28 |
29 | function videoReady(){
30 | console.log(classifier)
31 | }
32 |
33 | function addNoMask(){
34 | classifier.addImage(video, "draagt geen masker", addedImage)
35 | }
36 |
37 | function addMask() {
38 | classifier.addImage(video, "draagt masker", addedImage)
39 | }
40 |
41 | function train(){
42 | console.log("start training...")
43 | classifier.train((lossValue) => {
44 | console.log(lossValue)
45 | if(lossValue == null){
46 | startClassifying()
47 | }
48 | })
49 | }
50 |
51 | function startClassifying(){
52 | setInterval(()=>{
53 | classifier.classify(video, (err, result)=>{
54 | if(err) console.log(err)
55 | console.log(result)
56 | label.innerHTML = result[0].label
57 | })
58 | }, 1000)
59 | }
60 |
61 | function addedImage(){
62 | console.log("added image to network")
63 | }
--------------------------------------------------------------------------------
/snippets/extractfeatures/features.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HR-CMGT/Javascript-Machine-Learning/27c11a2574796d602f6970daebc28f233809d22c/snippets/extractfeatures/features.png
--------------------------------------------------------------------------------
/snippets/extractfeatures/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |