Working in Knowledge Science, it may be arduous to share insights from advanced datasets utilizing solely static figures. All of the sides that describe the form and which means of attention-grabbing knowledge will not be all the time captured in a handful of pre-generated figures. Whereas we’ve highly effective applied sciences out there for presenting interactive figures — the place a viewer can rotate, filter, zoom, and customarily discover advanced knowledge — they all the time include tradeoffs.
Right here I current my expertise utilizing a just lately launched Python library — marimo — which opens up thrilling new alternatives for publishing interactive visualizations throughout your complete subject of information science.
Interactive Knowledge Visualization
The tradeoffs to contemplate when deciding on an strategy for presenting knowledge visualizations may be damaged into three classes:
- Capabilities — what visualizations and interactivity am I in a position to current to the consumer?
- Publication Price — what are the assets wanted for displaying this visualization to customers (e.g. operating servers, internet hosting web sites)?
- Ease of Use – how a lot of a brand new skillset / codebase do I have to be taught upfront?
JavaScript is the inspiration of transportable interactivity. Each consumer has an internet browser put in on their laptop and there are lots of completely different frameworks out there for displaying any diploma of interactivity or visualization you may think (for instance, this gallery of fantastic issues folks have made with three.js). For the reason that utility is operating on the consumer’s laptop, no pricey servers are wanted. Nevertheless, a major downside for the information science neighborhood is ease of use, as JS doesn’t have lots of the high-level (i.e. easy-to-use) libraries that knowledge scientists use for knowledge manipulation, plotting, and interactivity.
Python supplies a helpful level of comparability. Due to its regularly rising recognition, some have referred to as this the “Period of Python”. For knowledge scientists particularly, Python stands alongside R as one of many foundational languages for rapidly and successfully wielding advanced knowledge. Whereas Python could also be simpler to make use of than Javascript, there are fewer choices for presenting interactive visualizations. Some widespread initiatives offering interactivity and visualization have been Flask, Sprint, and Streamlit (additionally price mentioning — bokeh, HoloViews, altair, and plotly). The largest tradeoff for utilizing Python has been the fee for publishing – delivering the software to customers. In the identical method that shinyapps require a operating laptop to serve up the visualization, these Python-based frameworks have solely been server-based. That is under no circumstances prohibitive for authors with a price range to spend, however it does restrict the variety of customers who can benefit from a specific undertaking.
Pyodide is an intriguing center floor — Python code operating straight within the net browser utilizing WebAssembly (WASM). There are useful resource limitations (only one thread and 2GB reminiscence) that make this impractical for doing the heavy lifting of information science. Nevertheless, this may be greater than ample for constructing visualizations and updating primarily based on consumer enter. As a result of it runs within the browser, no servers are required for internet hosting. Instruments that use Pyodide as a basis are attention-grabbing to discover as a result of they offer knowledge scientists a possibility to jot down Python code which runs straight on customers’ computer systems with out their having to put in or run something exterior of the net browser.
As an apart, I’ve been beforehand in one undertaking that has tried this strategy: stlite, an in-browser implementation of Streamlit that permits you to deploy these versatile and highly effective apps to a broad vary of customers. Nevertheless, a core limitation is that Streamlit itself is distinct from stlite (the port of Streamlit to WASM), which signifies that not all options are supported and that development of the undertaking depends on two separate teams working alongside suitable strains.
Introducing: Marimo
This brings us to Marimo.
The first public bulletins of marimo have been in January 2024, so the undertaking could be very new, and it has a singular mixture of options:
- The interface resembles a Jupyter pocket book, which will probably be acquainted to customers.
- Execution of cells is reactive, in order that updating one cell will rerun all cells which depend upon its output.
- Consumer enter may be captured with a versatile set of UI parts.
- Notebooks may be rapidly transformed into apps, hiding the code and displaying solely the enter/output components.
- Apps may be run regionally or transformed into static webpages utilizing WASM/Pyodide.
marimo balances the tradeoffs of expertise in a method that’s nicely suited to the talent set of the everyday knowledge scientists:
- Capabilities — consumer enter and visible show options are quite in depth, supporting consumer enter through Altair and Plotly plots.
- Publication Price — deploying as static webpages is principally free — no servers required
- Ease of Use — for customers conversant in Python notebooks, marimo will really feel very acquainted and be straightforward to select up.
Publishing Marimo Apps on the Internet
The very best place to begin with marimo is by studying their in depth documentation.
As a easy instance of the kind of show that may be helpful in knowledge science, consisting of explanatory textual content interspersed with interactive shows, I’ve created a barebones GitHub repository. Strive it out your self right here.

Utilizing just a bit little bit of code, customers can:
- Connect supply datasets
- Generate visualizations with versatile interactivity
- Write narrative textual content describing their findings
- Publish to the net without cost (i.e. utilizing GitHub Pages)
For extra particulars, learn their documentation on net publishing and template repository for deploying to GitHub Pages.
Public App / Personal Knowledge
This new expertise presents an thrilling new alternative for collaboration — publish the app publicly to the world, however customers can solely see particular datasets that they’ve permission to entry.
Reasonably than constructing a devoted knowledge backend for each app, consumer knowledge may be saved in a generic backend which may be securely authenticated and accessed utilizing a Python shopper library — all contained inside the consumer’s net browser. For instance, the consumer is given an OAuth login hyperlink that can authenticate them with the backend and permit the app to briefly entry enter knowledge.
As a proof of idea, I constructed a easy visualization app which connects to the Cirro knowledge platform, which is used at my establishment to handle scientific knowledge. Full disclosure: I used to be a part of the group that constructed this platform earlier than it spun out as an impartial firm. On this method customers can:
- Load the general public visualization app — hosted on GitHub Pages
- Join securely to their non-public knowledge retailer
- Load the suitable dataset for show
- Share a hyperlink which can direct licensed collaborators to the identical knowledge
Strive it out your self right here.

As an information scientist, this strategy of publishing free and open-source visualization apps which can be utilized to work together with non-public datasets is extraordinarily thrilling. Constructing and publishing a brand new app can take hours and days as a substitute of weeks and years, letting researchers rapidly share their insights with collaborators after which publish them to the broader world.