-

- -

Showing posts with label d3. Show all posts
Showing posts with label d3. Show all posts

Friday, February 19, 2021

Artificial Intelligence In JavaScript

.

Artificial Intelligence

AI in JavaScript

These days, several JavaScript AI framework are emerging.

JavaScript frameworks make it possible to execute AI tasks in the browser.

AI and JavaScript

Artificial Intelligence has changed the science of image processing, computer vision, and natural language applications.

Thanks to new AI libraries, JavaScript developers can now build machine learning and deep learning applications without Python or R. This way JavaScript can help developers to bring AI to the browser and to the web.


Is JavaScript Good for AI?

Most AI applications these days use R or Python.

But JavaScript has a great future as an AI language, and it even has a some advantages:

  • JS is better known. All developers can use it.
  • Security is built in. JS cannot access your files.
  • JS is faster than Python.
  • Modern JS compiles into machine code.
  • Modern JS can use hardware acceleration.

WebGL API

WebGL is a JavaScript API for rendering 2d and 3D graphics in any browser.

WebGL can run on both integrated and stanalone graphic cards in any PC.

WebGL brings 3D graphics to the web browser. Major browser vendors Apple (Safari), Google (Chrome), Microsoft (Edge), and Mozilla (Firefox) are members of the WebGL Working Group.

WebGL 1.0 was released in March 2011.

WebGL 2.0 was released in January 2017.

JellyFish


TensorFlow Playground

TensorFlow Playground is a web application written in d3.js.

With TensorFlow Playground you can learn about Neural Networks (NN) without math.

In your own Web Browser you can create a Neural Network and see the result.


Plotting in JavaScript

01234567891516171819

Plotting provided by: Plotly

.

https://web.archive.org/web/20210220012909/https://www.w3schools.com/ai/ai_javascript.asp

.

Monday, October 8, 2018

Using ObservableHq Online (Notebook) Editor For JavaScript ML Programming Like Python Jupyter Notebook

 


.

Observable is not just another JavaScript sandbox. It introduces the notebook paradigm to JavaScript projects, those of you familiar with Jupyter notebooks, this is the equivalent with JavaScript instead of Python. It turns out JavaScript is very well-suited to this type of paradigm.

What’s more, JavaScript developers already have some sort of familiarity with reactivity since most frontend frameworks and view libraries build on it. It’s a different kind of reactivity, in that the library only re-renders or re-computes the section of the application that needs it (cf. Vue, Angular, React).

.

https://codewithhugo.com/observablehq-notebooks-for-javascript-demos-and-prototypes/

Monday, October 24, 2016

tSNEJS: An implementation of t-SNE visualization algorithm in JavaScript

.

tSNEJS

tSNEJS is an implementation of t-SNE visualization algorithm in Javascript.

t-SNE is a visualization algorithm that embeds things in 2 or 3 dimensions. If you have some data and you can measure their pairwise differences, t-SNE visualization can help you identify clusters in your data. See example below.

Online demo

The main project website has a live example and more description.

https://cs.stanford.edu/people/karpathy/tsnejs/

https://cs.stanford.edu/people/karpathy/tsnejs/wordvecs.html

There is also the t-SNE CSV demo that allows you to simply paste CSV data into a textbox and tSNEJS computes and visualizes the embedding on the fly (no coding needed).



Research Paper

The algorithm was originally described in this paper:

L.J.P. van der Maaten and G.E. Hinton.
Visualizing High-Dimensional Data Using t-SNE. Journal of Machine Learning Research
9(Nov):2579-2605, 2008.

You can find the PDF here.

Example code

Import tsne.js into your document: <script src="tsne.js"></script> And then here is some example code:

var opt = {}
opt.epsilon = 10; // epsilon is learning rate (10 = default)
opt.perplexity = 30; // roughly how many neighbors each point influences (30 = default)
opt.dim = 2; // dimensionality of the embedding (2 = default)

var tsne = new tsnejs.tSNE(opt); // create a tSNE instance

// initialize data. Here we have 3 points and some example pairwise dissimilarities
var dists = [[1.0, 0.1, 0.2], [0.1, 1.0, 0.3], [0.2, 0.1, 1.0]];
tsne.initDataDist(dists);

for(var k = 0; k < 500; k++) {
  tsne.step(); // every time you call this, solution gets better
}

var Y = tsne.getSolution(); // Y is an array of 2-D points that you can plot

The data can be passed to tSNEJS as a set of high-dimensional points using the tsne.initDataRaw(X) function, where X is an array of arrays (high-dimensional points that need to be embedded). The algorithm computes the Gaussian kernel over these points and then finds the appropriate embedding.

Web Demos

There are two web interfaces to this library that we are aware of:

  • By Andrej, here.
  • By Laurens, here, which takes data in different format and can also use Google Spreadsheet input.

About

Send questions to @karpathy.

.

PLEASE WAIT WHILE THE CODE LOADS THE DATA

See the Pen t-SNE CSV web demo by smartcomputing123 (@smartcomputing123) on CodePen.