Smoother Data Science through Ergonomic Aesthetics

Jupyter Notebook Tweaks & Shortcuts

Anyone who says aesthetics don’t impact work is deceiving themselves.

Look at Apple: They built a dominant tech empire by applying artistic minimalism to every aspect of their products, from physical design to user experience.

What word do we associate with iProducts? “Smooth”.

Curved edges: I can’t find a single sharp-cornered shape anywhere on the MacBook I’m writing this on.
Clouded texture: Not blazing shiny like polished lacquer. Faded yet clean.

The result of this is an experience I’d call “sleek”. The software defaults to flowing transitions rather than jarring jumps. Much effort is placed into ‘unifying’ cloud systems for storage and account-based sharing of content across devices.

Plenty of tech people use Mac environments instead of Windows, although there’s no shortage of arguments for why a Windows build is more powerful, customizable, price-efficient, etc. Why?

Ergonomics. If your tools make work better, you’ll do more work.

Jupyter

This is the reason I do most of my data science work in Jupyter. Notebooks allow you to write and run code in separate cells within the notebook environment.

This allows you to explore every aspect of your program in detail, and saves an unimaginable amount of time debugging (there’s even a nice debugger for JupyterLab). Cell output supports complex visual displays, as well as interactive graphs & input.

Notebooks are incredibly popular for statistical analysis & machine learning alike, for a simple reason: modular execution lets you learn faster.

If you want to build something you’ve never done, you won’t fully understand all of the code you find in tutorials or books. So write a few lines, run the cell and see what happens. Change a few more things, run again. Keep running.

That’s the experimental process, more or less. If you feel like you’re in over your head, exploring strange libraries and uncertain of what the next code block will do — you’re learning fast.

Image for post
Image for post

But how can we make the experience even smoother? That’s something I’ve occasionally asked myself since I started coding a year ago.

I’ve tested various tricks to improve my work experience, and I’ve compiled my favorite addons, keyboard shortcuts & tips here — because I really care that much about ergonomics.

Color Coding

The most important addon I use is Kyle Dunovan’s Jupyter Themes. Change that bright white background to something easier on the eyes (and download a red light filtering app too, since we spend so much time staring at screens late at night).

Find a code color scheme that really speaks to you. What do you find more readable? What (no, really) do you find more relaxing to look at for hours?

Here’s part of a cell from a bitcoin AI backtesting bot I’m working on. You’ll notice that I’m one of those people who uses dark mode in every application that has it enabled:

Image for post
Image for post

I care about color coding. Your primate ancestors spent millions of years evolving complex retinas, diverse rods and cones because seeing colourful fruit or noticing striped orange tigers was quite important.

Color matters. Seeing red enhances simple detail-oriented performance, while being surrounded by blue made participants perform better at more complex and creative problems.

Compared to someone who programmed COBOL on a black & white screen, I’m quite spoiled — I know this, but I seek harmonious coding environments all the same.

Table of Contents

When you start to fill up a notebook, it can be a hassle to navigate from section to section. NotebookExtensions, specifically the table of contents, has saved me literal hours of scrolling through notes trying to see where I left the few lines I’m looking for.

Image for post
Image for post

Simply prefix some markdown text with ‘#’ to write a header (or ‘##’ for sub-headers) and the ToC cell at the top does the rest. It automatically hyperlinks to the relevant section, so you can simply click the header you want to get back to. It even comes with an adjustable side ToC display, so you don’t have to scroll back to the top to realign.

Keyboard Shortcuts

The best way to get your workflow to is more mastery over your tools. The small things add up — if you learn 5 tricks and write 10% faster, you’ll have more time to google error codes & read documentation.

A full set of shortcuts can be found here, but I’ll list my favorites in no specific order.

Save time copying & pasting: Shift+M to merge the selected cell with the cell below. Ctrl+Shift+Minus to split a cell at your current position.

Tab-complete is fantastic for exploring new objects. Instantiate a new instance, then type object_name. and hit Tab to bring up a list of methods & properties built into that object.

Text navigation and highlighting:

|from htm.bindings.algorithms import SpatialPooler

Let’s say your position is at the | right before ‘from’. Hold down ALT & hit the right arrow key to jump your position to the end of the next word.

from| htm.bindings.algorithms import SpatialPooler

Command (⌘) + Right will take you to the end of your current line.

from htm.bindings.algorithms import SpatialPooler|

And here’s the best trick: hold down Shift while doing any of the above, and you’ll highlight whatever section you move through.
This is subtle but quite useful when you want to highlight a section of what you’ve just wrote to add parentheses (since Jupyter encloses the highlighted section in parentheses when you hit left/open parentheses).

You could also just hold Shift and hit the arrow keys one by one for more fine-grained highlight control, if double / triple clicking on text for word / line highlighting isn’t cutting it.

Keep it simple

The goal of all of this is to make work smoother; to reduce the amount of times your train of thought is interrupted by the necessity of fiddling with a finicky piece of your software environment.

Minimizing interruption leads to a more streamlined mind-state, in my experience. Think less about the mechanics of entering and executing your code and more about the insight behind it.

The singularity that this approaches, of course, is some kind of Brain-Computer-Interface where you control the mouse & keyboard by thinking. Whether or not we’d want to be fully plugged in is another question entirely, but until we can ask that question, you’ll see results by making work easier on yourself.

Written by

data scientist, machine learning engineer. passionate about ecology, biotech and AI. https://www.linkedin.com/in/mark-s-cleverley/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store