GETTING STARTED | DATA VISUALIZATION | KNIME ANALYTICS PLATFORM

Create an Interactive Dashboard with KNIME Components and Python

TL;DR: KNIME can be used to easily create dashboards which also let you download the results as individual PNG and Excel files

Markus Lauber
Low Code for Data Science

--

Just show me the Data App workflows:

You can use KNIME to quickly create interactive dashboards with your favourite low-code tool. With the bundled Python integration attractive graphics are easy to create and configure with minimal additional coding.

If you are interested in Data Apps and widgets in general I have several links at the end of this article. If you are more into videos there is my talk about “Advanced Visualizations with Python and KNIME also building a Data App” on YouTube:

In the first example, we have a database of Diamonds with their size and quality and try to explore the data with a small table of filtered results and a graphic that can be configured right within the workflow.

KNIME Workflow to build a Dashboard
KNIME Workflow to build a Dashboard (https://hub.knime.com/-/spaces/-/latest/~TLKpoogMHRKVMIxg/).

Numeric and string variables are extracted and can be fed to the Component and be presented to select the values and the categories. The selection will be used to filter the data (Cut = Premium) and then select the numeric variable (price) from which the TOP 10 values will be shown. You could feed your own data to the nodes and the extraction will be done dynamically.

select string variable and value to filter the data
The table with the TOP 10 values is being dynamically created and presented in the component’s view (https://hub.knime.com/-/spaces/-/latest/~TLKpoogMHRKVMIxg/)

The selected string variable (cut) will be used to group the numeric variable (price) and display the values in a Boxplot graphic which will directly be shown within the Component. The results will also be converted to a PNG file in the background and stored in a temporary folder to get an (individual) name with the current timestamp attached. The PNG file can then be downloaded from the component along with the selected TOP 10 values into an Excel file. You could of course adapt that and create your own table of results with other KNIME nodes (like GroupBy) and other graphics.

a grouped Boxplot and the option to download the results to PNG and Excel files
Boxplots are a good way to get an overview over a numeric variable by groups (https://hub.knime.com/-/spaces/-/latest/~TLKpoogMHRKVMIxg/)

Key to the functions is the Refresh Button which appears as the (yellow) “Execute” button in the figure above. Within the component, all functions are built using KNIME nodes. The widgets provide the dynamic elements and the refresh button would bring all that together and make it interactive.

The inner workings of the component producing the graphic and file
The inner workings of the component producing the graphic and file (https://hub.knime.com/-/spaces/-/latest/~TLKpoogMHRKVMIxg/)

The widgets are also used to fill the interface of the Component. One small button on the top opens up the “Composite View Layout” where you can create and edit how your interface will look like. You can have static and dynamic elements and also present graphics or data as tables.

Configure the Composite View Layout
Configure the Composite View Layout.

The components can be opened directly from the KNIME workflow, but they can also work as a web application if you start the workflow from the KNIME Business Hub. In this case, your users would not need their own KNIME version installed locally. You can build dashboards and data science tools with the whole of KNIME functions in the background — you also could use traditional programming languages like R and Python.

Another approach exploring the Diamonds dataset is creating a “Scatterplot with Trend-Line and Statistics”. If you want to learn more about this little widgets in the Data Apps you can read: “Explore the Wonderful World of KNIME Widgets”.

Use Python graphic packages like Seaborn and Matplotlib

If you want to go one step further, you can combine this approach with the bundled Python version in KNIME which comes with these graphic packages Matplotlib and Seaborn already included — you will just have to install the extension and would not have to deal with all Conda environments and stuff.

However, if you want to learn more about how to set up Python and KNIME you can see my Medium article “KNIME and Python — Setting up and managing Conda environments”.

Again we can select the variables to be used in the graphic but this time the graphic will be produced by a Python Script node. The variables created will be fed into a Python code framework which might just be adapted from existing Seaborn examples.

Boxenplots with Python package Seaborn in a KNIME Dashboard
Boxenplot Plotting large distributions (https://hub.knime.com/-/spaces/-/latest/~nbfX818PlGRUflhK/).

So while you have to deal with some code, you will not have to write everything on your own and you can easily adapt existing examples by simply filling in some KNIME Flow Variables with the “knio.flow_variables[…]” function from the KNIME/Python packages installed automatically with the extension.

Python code for Boxenplot Plotting large distributions

You have to deal with the Python code just once and your users won’t have to deal with it at all. And as you can see with several other examples of Python graphics on the KNIME Community Hub, you can adapt a wide range of graphics.

If you enjoyed this story you can also follow me in the KNIME forum and on the KNIME Community Hub with much more examples (https://hub.knime.com/mlauber71)

--

--

Markus Lauber
Low Code for Data Science

Senior Data Scientist working with KNIME, Python, R and Big Data Systems in the telco industry