<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Zaccheus Sia on Medium]]></title>
        <description><![CDATA[Stories by Zaccheus Sia on Medium]]></description>
        <link>https://medium.com/@zaccheussia?source=rss-b0212c4a6e6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BaN0HbpHuWQVZH9x-8pYEg.jpeg</url>
            <title>Stories by Zaccheus Sia on Medium</title>
            <link>https://medium.com/@zaccheussia?source=rss-b0212c4a6e6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:02:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zaccheussia/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Elegant Dashboards for Python ML Apps using Taipy GUI]]></title>
            <link>https://medium.com/@zaccheussia/elegant-dashboards-for-python-ml-apps-using-taipy-gui-6e3c59d70a1f?source=rss-b0212c4a6e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e3c59d70a1f</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[taipy]]></category>
            <dc:creator><![CDATA[Zaccheus Sia]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 12:26:42 GMT</pubDate>
            <atom:updated>2022-06-17T12:26:42.676Z</atom:updated>
            <content:encoded><![CDATA[<p>Exploring a low code Python library for data science projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yWCcVd2_nRWKOIU7x-Ymww.gif" /><figcaption>A simple GUI built using Taipy.</figcaption></figure><h3>Table of Contents</h3><ul><li><a href="#699d">Why Use Dashboards?</a></li><li><a href="#da4e">Building Dashboards Using Taipy GUI</a></li><li><a href="#b628">Taipy GUI — A Bare-bones Example</a></li><li><a href="#416e">Exploring Penguins</a> (Hands-on demo)<br>1. <a href="#f704">Load the Dataset</a><br>2. <a href="#a121">Visual Elements</a><br>3. <a href="#0179">Selector</a><br>4. <a href="#4a7a">Indicator</a><br>5. <a href="#fa66">Chart</a><br>6. <a href="#29fb">Layout</a><br>7. <a href="#1f16">Button, Dialog Box and Table</a><br>8. <a href="#ad00">Global Callback Function</a><br>9. <a href="#ff9e">Putting It All Together</a></li><li><a href="#c43d">Final Thoughts</a></li></ul><h3>Why Use Dashboards?</h3><p>Can’t I just use my Jupyter Notebook and Altair? Well, that’s what I used to do too, until I had a need to switch back and forth between many different parameters of a plot. I could either:</p><ol><li>Change those parameters and <strong>rerun the cell repeatedly</strong> to see the updated plot; or</li><li>Generate all the plots immediately, but end up having to <strong>scroll through a long list of plots</strong>.</li></ol><p>Furthermore, in my use case, the code in the notebook was just polluting what I actually wanted to see — the plots and metrics that I was interested in.</p><p>There’s a much more intelligent way of doing this with dashboards. By creating a dashboard, I’m able to:</p><ol><li>Modify the parameters of my problem with on-screen widgets, quickly exploring the search space with immediate visual feedback; and</li><li>Allow non-technical stakeholders to use the same intuitive platform to appreciate what they’re paying for.</li></ol><h3>Building Dashboards Using Taipy GUI</h3><p>If your first thought is “but who has the time to be developing dashboards”, worry not. Developing dashboards is actually pleasantly trivial with Taipy, a low-code data science library.</p><p>Install <a href="http://taipy.io/">Taipy</a> with Pip.</p><pre>pip install taipy</pre><p>Taipy comes with two main components:</p><ol><li>Taipy Core, a framework for efficient scheduling of tasks and scenario management; and</li><li>Taipy GUI, a frontend component and the subject of this article.</li></ol><p>Although the developers of Taipy advocate the synergy of using Taipy Core and Taipy GUI together, I was primarily interested in creating a dashboard, and so I focused exclusively on Taipy GUI.</p><p>With absolutely no knowledge of frontend languages (HTML, CSS, etc), I was able to build a fully functioning web application.</p><h3>Taipy GUI — A Bare-bones Example</h3><p>To demonstrate the simplicity and elegance of Taipy, let’s take a look at the following code snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a50631a82abdf7488c3d2551058d389b/href">https://medium.com/media/a50631a82abdf7488c3d2551058d389b/href</a></iframe><p>In just a few lines of intuitive code, Taipy has created a webpage and serves it for us via a web server running on the local machine. Taipy also opened our default browser and navigated to localhost:5000, where we now see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*_13YQaoGZqzesmNZtr8EzQ.png" /><figcaption>A “hello world” webpage built with Taipy.</figcaption></figure><p>The content of the GUI is stored in the variable md, a multi-line string. The <strong>text is formatted with Markdown</strong>, as you may recognise by the familiar syntax used for the header, bold text and italicized text in the example above.</p><p>Interpolation of the website variable was done using the &lt;|…|&gt; syntax specified in Taipy — <strong>a recurring construct as part of Taipy GUI’s augmented Markdown</strong>, which will be explained further in the next section.</p><h3>Exploring Penguins</h3><p>To further explore the capabilities of Taipy GUI and what it can do for us, let’s create a dashboard to explore the <a href="https://github.com/allisonhorst/palmerpenguins"><em>palmerpenguins dataset</em></a>. Specifically, in this example, we will use the following features of Taipy GUI:</p><ul><li>Selectors</li><li>Buttons</li><li>Charts</li><li>Tables</li><li>Pop-up dialog boxes</li></ul><p>The final dashboard will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HOO4LpzKwS5ArJ-kmLmTQg.png" /><figcaption>The dashboard which we will build using Taipy GUI.</figcaption></figure><p><strong>You can find the complete code for the dashboard above at the end of this article.</strong></p><h4>1. Load the Dataset</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c41ac23595fc2e9d542c0f0f8a75aad/href">https://medium.com/media/5c41ac23595fc2e9d542c0f0f8a75aad/href</a></iframe><p>We begin by loading the DataFrame from the <em>palmerpenguins</em> GitHub repository. The following table shows the data stored, whose columns are quite self-explanatory:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc380570aa837d23ba70ae79d47d5716/href">https://medium.com/media/cc380570aa837d23ba70ae79d47d5716/href</a></iframe><h4>2. Visual Elements</h4><p>Visual elements such as buttons, selectors and charts are created in Taipy by <strong>introducing a new syntax into the Markdown</strong>. Substrings with the pattern &lt;|…|…|&gt; (angle brackets with <em>properties</em> bordered with pipes) in the string passed to the taipy.gui.Gui object are parsed into different types of visual elements.</p><h4>3. Selector</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*7XOJEV_YpOyeTTzgsqCHfQ.gif" /><figcaption>The “selector” (top) and “indicator” (bottom) controls in Taipy GUI.</figcaption></figure><p>Let’s begin by building the penguin species <strong>selector</strong> on the left panel of the dashboard.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af8ff4fe4fa38eb9c36fedc3ff35e608/href">https://medium.com/media/af8ff4fe4fa38eb9c36fedc3ff35e608/href</a></iframe><p>As a reminder, Taipy GUI parses the string as Markdown, so the ### simply defines a level-3 header. The more interesting part however is the Taipy selector definition.</p><p>This construct has 5 components (bordered by the pipes). Here’s what they do:</p><ul><li><em>{species}</em> : The variable which holds the initial value of the selector — “Adelie” in this case.</li><li><em>selector</em> : The name of the Taipy visual element.</li><li><em>lov={target_names}</em> : The list of values (<em>lov</em>) that the species may be be selected from.</li><li><em>dropdown=True</em> : Indicates that we want the selector to use a dropdown menu.</li><li><em>width=100%</em> : Sets the width of the selector to the full size of its parent container.</li></ul><p>Refer to the <a href="https://docs.taipy.io/en/latest/manuals/gui/viselements/selector/">Taipy selectors</a> documentation for more information.</p><h4>4. Indicator</h4><p>The next control we used is the <strong>indicator</strong> which displays a value of interest on a number line — in this case, the number of selected penguins out of all the penguins in the dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac127344bd5fae79b01eaaee76321646/href">https://medium.com/media/ac127344bd5fae79b01eaaee76321646/href</a></iframe><p>As can be inferred from this example, Taipy evaluates the expression inside curly braces and uses its result — just like an <em>f-string</em>.</p><p>Notice that the “value” property is separate from the first component. The first component (aptly named “display”) determines the displayed label, whereas the ”value” property determines its position on the number line. For example, the code &lt;|{“Fail”}|indicator|value=20|max=100|&gt; would generate the following indicator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*SHKkQ-ncd0AKHVRjulb6vQ.png" /><figcaption>An indicator with a value of 20, displaying the label “Fail”.</figcaption></figure><p>Refer to the <a href="https://docs.taipy.io/en/latest/manuals/gui/viselements/indicator/">Taipy indicators</a> documentation for more information.</p><h4>5. Chart</h4><p>Under the hood, <strong>Taipy uses the </strong><a href="https://plotly.com/"><strong><em>Plotly</em></strong></a><strong> graphing library to generate its charts</strong>. If you’re already familiar with Plotly, you can probably figure out the type of chart the following code in this section would produce. For the uninitiated however (like me), this probably looks like mumbo jumbo.</p><p>Thankfully, the <strong>Taipy chart documentation provides ample examples</strong> which serve as an excellent primer for crafting several types of commonly used graphs.</p><p>Here’s the code for our chart:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb29db295f5b48dc5e13ae4e047a2c86/href">https://medium.com/media/eb29db295f5b48dc5e13ae4e047a2c86/href</a></iframe><p>And the resulting chart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*f6fO-Ye63zO3Z10K9xq2cA.png" /><figcaption>A scatter plot created using Taipy GUI.</figcaption></figure><p>The variable df, which is the DataFrame of the selected penguin species, is fed directly to the chart visual element construct. Then, additional properties are configured to style the chart as we like.</p><p>Putting properties such as “height” and “width” in the chart_properties <strong>dictionary and then passing it to “properties” in the Taipy visual element construct</strong> is a cleaner way of doing</p><pre>&lt;|{df}|chart|…|height=35vh|width=40vw|…|&gt;</pre><p>which would have resulted in a very long line.</p><p>Refer to the <a href="https://docs.taipy.io/en/latest/manuals/gui/viselements/chart/">Taipy chart</a> documentation for more information.</p><h4>6. Layout</h4><p>Creating the panel on the left is extremely simple to do. The <strong>layout</strong> element can be used to create columns. Remember that in our example, we created three columns: one for the left panel and two for the charts.</p><p>The basic syntax for creating a layout is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d22d1b21f0eb455c3536ebe0fc0a9e7/href">https://medium.com/media/3d22d1b21f0eb455c3536ebe0fc0a9e7/href</a></iframe><p>Here, I created a layout with two columns, with the size ratio of 1:6. Notice that the content section was wrapped in &lt;| and |&gt; on new lines. This is known as a <strong>part</strong> in Taipy. We needed this for the content section because the <strong>layout</strong> expects two columns — one to render on the left, and one on the right. The standalone text for the left panel gets put in the first column, while the entirety of the <strong>part</strong> block gets put in the second column.</p><p>Optionally, a <strong>part</strong> can also be defined by starting with &lt;|part.start|&gt; on a line and ending with &lt;|part.end|&gt; on another line. Any lines between the start and end constructs will belong to the part. We will use this slightly more verbose syntax in the final code as it is more readable.</p><p>Running the script above gives us this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*G1dlnqW3rXWmjU43jGCihw.png" /><figcaption>2-column layout.</figcaption></figure><p>Refer to the <a href="https://docs.taipy.io/en/latest/manuals/gui/blocks/">Taipy blocks</a> documentation for more information on layouts and parts.</p><h4>7. Button, Dialog Box and Table</h4><p>The last feature we’ll add to our dashboard is a <strong>table</strong> to display the penguin_df DataFrame. Better yet, we’re going to put this table in a <strong>dialog</strong> page, which gets displayed when we click a <strong>button</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SnF7hgxms8hKALstOOLSgg.gif" /><figcaption>The button which brings up a dialog with our dataset displayed in a table.</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f0f337efb21ebc30357efd43fb19299/href">https://medium.com/media/4f0f337efb21ebc30357efd43fb19299/href</a></iframe><p>Let’s take a minute to digest this code which is a little bit more complex than the previous sections.</p><p>Aside from the penguin_df variable which is a DataFrame that we imported earlier, we’re using two other names to create this section:</p><ul><li><em>show_table_dialog</em> : A boolean which determines if the dialog is shown or hidden; and</li><li><em>toggle_table_dialog</em> : A function which toggles the <em>Taipy GUI </em><strong><em>State</em></strong><em> application variable</em> for the <em>show_table_dialog</em> variable.</li></ul><p>But what is this <strong>State</strong>? Effectively, each variable that we have included in our Taipy application is actually copied into a taipy.gui.State object. In other words, <strong>they exist separately in memory from the initial variables we defined</strong> in the local namespace. Opening two different tabs of this Taipy application in your web browser actually creates two different <strong>State</strong> instances — meaning they can be used independently as they have separate state.</p><p>Returning to our code, the toggle_table_dialog function we declared receives one parameter, which we named state. In our Markdown, the button and dialog constructs both defined an <strong>on_action</strong> property which we assigned our toggle_table_dialog, otherwise known as a callback function. Now, whenever the button or the dialog is interacted with (the latter by clicking the “x” or “Cancel” controls), the toggle_table_dialog callback function is called, which <strong>toggles the state variable of </strong><strong>show_table_dialog</strong>.</p><p>Refer to the Taipy documentation on <a href="https://docs.taipy.io/en/latest/manuals/gui/viselements/button/">buttons</a>, <a href="https://docs.taipy.io/en/latest/manuals/gui/viselements/dialog/">dialogs</a> and <a href="https://docs.taipy.io/en/latest/manuals/gui/viselements/table/">tables</a> for more information.</p><h4>8. Global Callback Function</h4><p>Finally, we need to add one last component to complete this dashboard: a <strong>global callback function</strong>. Unlike the previous section where we defined a specific callback function to toggle the dialog, Taipy GUI also offers the use of a global callback function, i.e., a function which <strong>gets called whenever any application variable is modified</strong>.</p><p>In this section, we will use the global callback function to modify the application’s df state variable. To recap, penguin_df is the full imported dataset, while df is a subset based on the selected penguin species.</p><p>Let’s define on_change, our global callback function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bec60fbe19c1d5db9198a6726e572913/href">https://medium.com/media/bec60fbe19c1d5db9198a6726e572913/href</a></iframe><p>This function takes 3 parameters:</p><ul><li><em>state</em> : The taipy.gui.State object;</li><li><em>var_name</em> : The <strong>name</strong> of the application variable that was modified; and</li><li><em>var_value</em> : The <strong>value</strong> of the application variable that was modified.</li></ul><p>In other words, because of our print statement, if we were to change the penguin species from “Adelie” to “Gentoo”, we would see the following text printed out in our terminal:</p><pre>species &lt;class &#39;str&#39;&gt; Gentoo</pre><p>As previously mentioned, the global callback function is called whenever <strong>any</strong> application state variable is modified, whether by interacting with the GUI, or programatically. This is a handy feature which I use a lot to implement functionality that needs to run whenever any visual element is modified.</p><p>Taipy automatically uses any function with the name on_change in the local namespace as the global callback function — but in the next section I will also show you how you can explicitly configure Taipy to use a function with some other name.</p><h4>9. Putting It All Together</h4><p>Putting together all the components that we built in the previous sections, we get the simple but complete dashboard which we saw at the beginning of this article:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20c765eb50bb45b18f534d34be6fd610/href">https://medium.com/media/20c765eb50bb45b18f534d34be6fd610/href</a></iframe><p>As mentioned earlier, notice the (optional) explicit assignment of the global callback function which we defined, by assigning it to the on_change member of the Gui object. This isn’t strictly necessary because Taipy would use the function specifically named on_change in the local namespace, but explicit assignment would have been required otherwise.</p><p>Try installing Taipy on your machine and running this script! You will be running the very same dashboard on your local machine. Check out the <a href="https://docs.taipy.io/en/latest/manuals/gui/controls/">Taipy controls</a> documentation and try adding sliders or toggles to the dashboard which are just as easy (or easier!) to use.</p><h4>Final Thoughts</h4><p>Before discovering Taipy, my go-to dashboarding library in Python was Streamlit — an established library which I also found to be very easy to use. Although my experience with simple mock-ups and prototyping was pleasant, developing a larger application with multiple pages and state management was quite frustrating — as these more complex applications seem to lay outside of the scope that Streamlit excels in.</p><p>Taipy offers a lot of customisability which caters to developers that wish to design a very specific user experience — but also <strong>reasonable defaults</strong> for developers that want to quickly create simple applications. Creating multi-page applications, managing shared state between different pages and styling with CSS are just a few of the many things you can do with Taipy GUI.</p><p>Give <a href="http://taipy.io/">Taipy</a> a try, and let me know if you liked it as much as I did!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e3c59d70a1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>