Introducing Jaal — Interacting with Network Made Easy

Your interactive network visualizing dashboard in Python

Mohit Mayank
Towards Data Science

--

Photo by Ella Baxter on Unsplash

Visit the package’s github page for code and detailed readme. Also, if you like it, please don’t shy from clicking on the star 😏

👉 Preface

Not long ago I posted an article introducing several network visualizing tools in Python. The response was phenomenal. The best part was the messages where people shared their experiences, preferences and problems. One interesting point was how many were excited about one of the options, but it required a lot of boilerplate code to get started. This problem was the catalyst for Jaal, where I have tried to remove all of the frills required to plot a network in Python using Dash and visdcc. Apart from that, I have also tried to add some of the most common interactions I personally feel a network visualization tool should have. So without further ado, let’s dive into the Jaal 😄

👉What is Jaal

Jaal is a python based interactive network visualizing tool built using Dash and Visdcc. As it’s built using Dash, we can consider it as more of a dashboard rather than a network plot. Because of this, along with the basic features, Jaal also provides multiple options to play with the network data such as searching, filtering and even colouring nodes and edges in the graph. And all of this within 2 lines of codes :)

👉Install

Installing Jaal is super easy, just run the following,

pip install jaal

And you are done 😆

Note, it’s recommended to create a virtual environment before installing. This can be easily done using python -m venv myenv and then to activate the environment we run,

  1. (Windows) .\\myvenv\\Scripts\\activate.bat
  2. (Linux) source myvenv/bin/activate

👉Getting started

After installing Jaal, we need to fetch the data and call plot function in Jaal. Let’s do this by playing with Game of Thrones dataset which is included in the package. The complete code to fetch the data and plot is as follows,

Here first we import Jaal main class and the dataset loading function load_got. Later we loaded the GoT dataset from the package. This gives us two files,

  1. edge_df: it's a pandas dataframe with at least from and to columns, which represents the edge relationship between the entities
  2. node_df: it's a pandas dataframe with at least id column which contains the unique node names
5 rows from edge_df (left) and node_df (right). Apart from the mandatory columns, weight and strength are the features of the edges. Similarly, gender is a feature of nodes.

Note, edge_df is mandatory and node_df is optional. Also, we can include additional columns in these files which are automatically considered as edge or node features respectively.

Next, we pass the data into Jaal and call plot. This will lead the console to prompt the default localhost address (127:0.0.1:8050) where Jaal is running. We can access it to see the following dashboard,

Jaal dashboard with settings panel on the left and graph on the right.

Features

At present, the dashboard consist of the following sections,

  1. Settings panel: here we have multiple options to play with the graph data. It further contains the following sub-sections,
  • Search: can be used to highlight a node in the graph
  • Filter: supports pandas query language and can be used to filter the graph data based on nodes or edge features.
  • Color: can be used to color nodes or edges based on their categorical features. Note, currently only features with at max 20 cardinality are supported.

2. Graph: the network graph plotted using visdcc.

👉Examples

Let’s go through the example of each of the features we discussed above one by one. We will use the GoT dataset.

1. Searching

The first option is searching, where we can search for a specific node in the graph. It supports character by character search on the node labels. Below is an example where we are trying to search for “Arya”,

2. Filtering

Next, we have filtering. Jaal supports the option to search on both node and edges features. For this, we provide separate text areas. Below we can see the live effect of node and edge filtering query.

3. Coloring

Finally, instead of filtering, we may want to see the overall distribution of any feature. Currently, Jaal handles this by providing the option to color nodes or edges based on any categorical feature. We can see a live-action example below.

Conclusion

The intention of this article was to introduce a new python package called Jaal. The package is inspired by the messages, comments and reaction due to a recent post on network visualization by several like-minded people. This is an effort to mitigate some of the pain areas we face while trying to visualize and play with network data. Hope this could be of help. Also, this is just the first version of Jaal, there are many more features I would love to add. For this, any collaborations or ideas are greatly appreciated. See you guys in the next one!

Cheers.

Connect with me on LinkedIn and read similar articles on my website.

--

--

Senior Data Scientist | AI/ML Researcher | Creator of “Jaal” | Author of “Lazy Data Science Guide” | Linkedin & Twitter: @imohitmayank