My Jupyter Notebooks Setup
I’ve been working with machine learning models for a while now, but recent trends in the field have made me realize the need to deepen my understanding and skills. I’ve decided to dedicate this month to diving into various machine learning algorithms and techniques.
Workining on my project I’ve realized that while Python’s rapid prototyping capabilities make it a popular choice for many, the reality is that production environments often demand languages like JavaScript or Go.
To bridge the gap between prototyping and production, I’ve decided to use JavaScript and Go in my Jupyter Notebook workflow. By using JavaScript for visualizations, I can seamlessly transition these elements into the final application. Additionally, TinyGo (a WebAssembly compiler for Go) could potentially bring some models to the browser. I’ll write about TinyGo in a future post.
Deno Runtime
Deno is a javascript runtime that aims to bring no-build environment for developing modern js backends. At least this is how I see their place in the market. I believe it’s currently the most promising option for using JavaScript within Jupyter Notebooks.
The installation process is as simple as:
curl -fsSL https://deno.land/install.sh | sh
deno jupyter --install
Go in Notebooks
For Golang I picked gonb. Because at the time it is most feature-rich and updated golang kernel for Jupyter.
The install process is also straight-forward:
go install github.com/janpfeifer/gonb@latest
go install golang.org/x/tools/cmd/goimports@latest
go install golang.org/x/tools/gopls@latest
gonb --install
Notebooks
I use Jupyter in the docker environment because I have different workstation for ML tasks. You can find my docker setup in following repository: l12.xyz/x/docker-notebook.
Libraries
The best option to draw charts I’ve found is Observable Plot:
import * as Plot from "npm:@observablehq/plot";
At the time, the only good option for dataframes is Pola-rs:
import pl from "npm:nodejs-polars";
let data = ',,,'
let df = pl.readCSV(data, { sep: "," });
See full examples on Deno blog.
At the time I am not interested to use plots with Golang, but gonb
authors suggest some options
I am intersted in numpy and scikit aternatives. The most promising library i’ve found is GoNum, and a lot of different implementations for regressions, knn and other common algorithms.
Conclusions
In many ways, Jupyter has become as indispensable to me as my traditional IDE. Here are a few reasons why I use it daily:
Fast prototyping
While Jupyter is often associated with machine learning tasks, it’s also a powerful tool for rapid prototyping. The availability of JavaScript and Go kernels allows me to quickly test and refine my ideas.
Allignment with my goals
My current focus is on deploying simple machine learning models to the browser and cloud functions using WebAssembly without relying on tensorflow.js or other heavy libraries. I believe this approach has significant potential in areas like ad-blocking, advertising, and web analytics. I’ll share my findings on this topic in a future post.