Top 5 Jupyter Widgets to boost your productivity!

Original article was published on Becoming Human: Artificial Intelligence Magazine

A guide to install, configure and use the most useful jupyter widgets.

Photo by Safar Safarov on Unsplash

We can’t thank Project Jupyter enough for bringing in those versatile and interactive IPython notebooks, FOR FREE!. Hands down, jupyter has changed the way experimentation is done using conventional scripts and has become the De facto of modern-day python programming. Why is it so well known? Why is everyone using it? because:

  1. Each cell can be modified at any point of time even when the program is running.
  2. Documentation using jupyter notebooks is a cup of tea, export your notebook as a PDF, make it into a python script or export it as an HTML file.
  3. Complete output is visible for every cell.
  4. Step-by-Step implementation of complex algorithms makes it easy to progress with the project.
  5. Jupyter maintains state of notebook therefore code can be undone and deleted cells can be restored.

Now that we know why jupyter is a must, let’s take a look at how we can improve it further to make the experience even more streamlined.

Introducing Notebook Widgets!

Photo by Ryoji Iwata on Unsplash

Jupyter widgets enhance the jupyter experience by introducing liveliness to your notebooks and are useful for tasks such as easy navigation, smooth presentations, template generation, code formatting and hassle less visualisations. Let’s straightaway dive into it.

Trending AI Articles:

1. Natural Language Generation:
The Commercial State of the Art in 2020

2. This Entire Article Was Written by Open AI’s GPT2

3. Learning To Classify Images Without Labels

4.Becoming a Data Scientist, Data Analyst, Financial Analyst and Research Analyst

Prerequisite installations:

Using condo package manager:

conda install -c conda-forge jupyter_contrib_nbextensions
conda install -c conda-forge jupyter_nbextensions_configurator

Using pip package manager:

pip install jupyter_nbextensions_configurator jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextensions_configurator enable --user

Now the type following command in terminal and launch jupyter notebook

jupyter notebook

You must see the following addition in the menu

Image by author

Uncheck the following button to start using widgets!

Image by author

Now that you have done that we are ready to go!

For activating a widget search for the name in the search bar as indicated above and check the button.

  1. Collapsible headings

One of my absolute favourites is collapsible headings widget which allows you to enclose a snippet of code within a heading until next heading of the same size is found. Sometimes the programs get too long and reach to a point where navigation through the code is a tedious task. Use this widget to hide long scripts of code and make your notebook more presentable and easy to understand.

Image by author

2. Autopep8

“You primarily write your code to communicate with other coders, and, to a lesser extent, to impose your will on the computer.”
 — Guido van Rossum, Python founder

Another widget to make your code more presentable is Autopep8. PEP stands for Python Enhancement Proposal, it is a style for writing python code to make it more readable and understandable. It defines a few formatting conventions such as:

  • While writing a function use a lowercase word or words. Separate words by underscores to improve readability — my_func(), prime()
  • While declaring a variable use a lowercase single letter, word, or words. Separate words with underscores to improve readability — count, df, first_list
  • While declaring a constant use an uppercase single letter, word, or words. Separate words with underscores to improve readability — BASE_PATH,DIMS,ITERATIONS
Machine Learning Jobs

That’s exactly what Autopep8 does for you automatically! Have a look at the before and after:

Image by author

All you have to do is just click on the cell you want to correct the formatting of and hit the button below which should be on your jupyter toolbar:

Image by author

3. Notify

If the task at hand is time consuming then having a widget which can notify user on completing cell execution can be quite handy. One such extension is notify, it basically sends a browser notification every time a cell completes its execution. Say today you have to work on retrieving data from remote databases or perform complex operations on a large dataframe and it is taking so long that you almost forget about its execution, later you check on after an hour and find out it had completed execution half an hour earlier, to avoid the frustration that will follow you can simply use this widget 🙂

Image by author

Do not forget to allow notifications access to jupyter.

4. Code folding

Like other IDEs such as PyCharm or Eclipse, code folding can also be used in jupyter using the Code folding widget. Here’s an example:

Image by author

It’s a pretty simple tool and is just plug-and-play, doesn’t require any setup.

5. Hinterland

Hinterland is an auto-complete extension for jupyter that provides suggestions as you type and it works quite well. If you are among those who tend to write repetitive code for any reason, hinterland is the thing for you!. Look at this demo:

Image by author

Conclusion:

These were some of the most used jupyter widgets to help programmers better manage the code they write, explore more and use those suites you. Do let me know if you find any interesting widgets! Till then, see you next time.

Previous blogs:

Don’t forget to give us your 👏 !


Top 5 Jupyter Widgets to boost your productivity! was originally published in Becoming Human: Artificial Intelligence Magazine on Medium, where people are continuing the conversation by highlighting and responding to this story.