The rise of JavaScript in machine learning

Machine Learning


NEW YORK — Laurie Lay, senior software engineer at Ippon Technologies, has good news for JavaScript developers. You don't need to master Python for machine learning (ML). Although Python clearly dominates this space, JavaScript and ML together offer front-end developers new ways to enhance their applications with on-device AI, he said.

Ray discussed what JavaScript and Node.js bring to new frontiers in AI at the devmio International JavaScript Conference, held from September 30th to October 30th. #1 in Brooklyn.

Why Python is the king of ML

According to Lay, Python has traditionally been a language for performing machine learning tasks, but Python's syntax lacked anything essential that made it a top machine learning language.

“For the past 10 years, serious discussions about machine learning have always been associated with the Python programming language, and this dominance was no accident, nor was it because Python is a very fast language,” she said. “The real reason is that Python has become the high-level glue language for the vast majority of other libraries.”

He said the heavy lifting in machine learning is not performed by the Python code itself, but by underlying libraries such as NumPy for numerical calculations and Pandas for data manipulation. These libraries are actually sophisticated Python wrappers around highly optimized low-level code written in C and Fortran, she continued.

Fullstack developer Laurie Lay talks about using JavaScript in machine learning.

Laurie Lay talks about JavaScript and machine learning. Photo by Lorraine Lawson.

“This architecture allows scientists and researchers to work with Python's simple, easy-to-read syntax while leveraging the raw computational speed of C for intensive mathematical operations,” she said. “This combination of ease of use and high performance has accelerated the development of machine learning.”

It didn't hurt, she said, that Python received significant early investment from companies like Google, which helped develop TensorFlow and hired Python's creator, Guido van Rossum.

“Funding, ease of use, and a strong community solidify Python's position in producing this rich ecosystem, tools, frameworks, and high-quality documentation,” she said.

If not Python, then JavaScript?

So the barrier to entry isn't really about Python syntax, she said, but about “replicating this large, veteran, low-level scientific computing ecosystem.” Python is the dominant language for offline model training, but things are about to change.

“The idea of ​​doing full-fledged machine learning in JavaScript is now a real reality, driven by a number of technological advances,” she said.

First is the speed of JavaScript engines such as Google V8. This has been dramatically improved by techniques such as just-in-time compilation, which runs JavaScript at speeds previously unimaginable in interpreted languages, she explained. Second, Node.js provides a robust and scalable server-side environment, freeing JavaScript from browser limitations.

There's also the npm ecosystem, which has created the world's largest software registry. This ecosystem fosters a culture of open collaboration and makes it easier to share and build complex tools, Ray said.

The npm ecosystem now includes a number of dedicated machine learning libraries that give developers the tools they need to build and train models in JavaScript. But more important changes have occurred since Python became the ML champion, she said.

“Perhaps the most impactful change is the continued improvement in the hardware of modern client devices, from your laptop to your pocket phone. These devices now have the computational power to actually run these sophisticated machine learning models locally,” Ray said. “And this has been a game-changer in everything.”

JavaScript for machine learning

Lay cautions that the goal is not to replace Python. It's about enabling machine learning on the client using JavaScript.

“It's about bringing machine learning into an environment where JavaScript is its native language: the web browser,” she said. “This opens up a new class of applications that would be very difficult or impossible to achieve with traditional server-centric architectures.”

“It’s about bringing machine learning into an environment where JavaScript is its native language: the web browser…”
– Laurie Lay, Senior Software Engineer, Ippon Technologies

Ray continued that running machine learning models on the client side enables many capabilities that were not possible before.

Traditional cloud-based AI models require users to send personal information and data such as photos, private messages and medical information to third-party servers for processing, he said. This poses inherent privacy and security risks. But on-device, machine learning using JavaScript can reduce these risks.

“When the learning model is run directly within the user's device, the data does not have to leave the device and remains private and secure,” she said. “This is critical for applications that handle sensitive information, such as medical, financial, and enterprise applications. We also see that by eliminating dependence on network connectivity, applications become faster and more reliable, and predictions become more instantaneous because applications can function offline.”

She added that each user will also be able to tweak and customize the model on their own device.

“For example, a product recommendation model can look at a user's image and adapt to that user's unique style and clothing without requiring the user to send private images to a separate server,” Ray said.

Advantages of nodes

According to Lay, Node.js also offers advantages for machine learning architectures.

She pointed out that while backend logic powered by Node exists in one world, complex numerical machine learning models written almost exclusively in Python exist in another.

To make them talk, developers had to build another Python microservice and wrap it with a Flask API (Flask is a lightweight, minimalist Python web framework that is also used to build APIs). Then I needed to make a network call from my Node app. Deployment is slow and complex, and introduces another point of failure, she added.

“The strength of Node is that it is built on an event-driven, non-blocking I/O model that leverages Chrome's V8. This makes Node very good at handling large numbers of concurrent web requests, and by adding machine learning capabilities directly to JavaScript code and Node servers, we have an ideal platform for delivering predictions from already trained machine learning models,” said Lay.

Node is ideal for building real-time applications such as intelligent chatbots, which can handle thousands of simultaneous conversations and process real-time data from connected devices, he added. This enables the creation of features such as a home assistant that can adjust the thermostat based on the people or pets in the room, and a live recommendation engine that provides personalized recommendations to a large user base with minimal delay.

Why you need JavaScript and Python for machine learning

“But one of the things I want to make sure to take away from this talk is that it's not a choice between Python and JavaScript,” Ray said. “One doesn't always take precedence over the other. The key is to leverage the strengths of each of these ecosystems for machine learning applications.”

She said Python remains superior when developers need to train models that require a lot of calculations. JavaScript is great for providing real-time, scalable APIs on the Node and client side. It also supports additional security and device-specific operations for applications.

“This is an evolution of the web platform that's happening right now, and as developers, we have the ability to build a new generation of these intelligent applications.”
– Laurie Ray

You can also take a hybrid approach, where developers train models in Python to optimize complex machine learning models. Models can be saved as JSON. Node allows coders to use libraries like TensorFlow that load pre-trained models into memory. Developers can then expose an API endpoint and client applications can call that pre-trained model to get predictions, she explained.

“This approach combines the power and maturity of a Python training environment with Node's lightning-fast multi-request performance and a robust, scalable architecture for deploying machine learning models,” she said.

Don't think that machine learning in the JavaScript ecosystem is a “passing trend,” she added.

“This is an evolution of the web platform that's happening right now, and as developers, we have the ability to build a new generation of these intelligent applications,” Ray said. “Many of our apps that are already built in JavaScript have the ability to keep application data localized, private, and real-time. This makes JavaScript a great language for deploying machine learning models to small, local, resource-constrained devices.”


group Created with sketch.





Source link