<?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 Marine Gosselin on Medium]]></title>
        <description><![CDATA[Stories by Marine Gosselin on Medium]]></description>
        <link>https://medium.com/@marine.gosselin?source=rss-ea1c64d90586------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WVO4ZJVW9m6iH7aPhTXARA.jpeg</url>
            <title>Stories by Marine Gosselin on Medium</title>
            <link>https://medium.com/@marine.gosselin?source=rss-ea1c64d90586------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:13:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marine.gosselin/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[Taipy or How to Remove Major Hurdles with Your AI/Data Projects]]></title>
            <link>https://medium.datadriveninvestor.com/taipy-or-how-to-remove-major-hurdles-with-your-ai-data-projects-34fd17507807?source=rss-ea1c64d90586------2</link>
            <guid isPermaLink="false">https://medium.com/p/34fd17507807</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Marine Gosselin]]></dc:creator>
            <pubDate>Thu, 21 Mar 2024 08:47:45 GMT</pubDate>
            <atom:updated>2024-03-22T07:08:08.882Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nals1p7LXEkyMgTs4pEwDg.png" /></figure><blockquote><em>Author: </em><a href="https://www.linkedin.com/in/vincent-gosselin-5011559/"><em>Vincent Gosselin</em></a></blockquote><p>Over the years, I have been involved in implementing many “smart software” projects that demonstrated high benefits to major organizations. At the heart of these different software projects were algorithms based on Mathematical Programming, Simulation, and Heuristics, as well as AI models based on ML and generative AI. Most of these projects led to substantial ROI for these organizations; some have even shaped their company’s future.‍</p><p>Despite all the hype around AI and Data, many organizations (outside of the software industry) struggle to implement a successful AI strategy. Most CIOs/CDOs involved have mostly produced “standard” data projects (data lakes/warehouses/data management/Dashboarding), some implemented several AI pilots, and very few have generated deployed projects showing substantial ROI for their company.</p><p>‍One could consider the distribution of companies in terms of AI penetration as a highly left-skewed fat-tail distribution.</p><p>‍‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*pdFHagVRdItddOkj.png" /></figure><p>‍The purpose of this article is not to list all the obstacles preventing the wider penetration of AI projects inside companies. For this purpose, I would recommend these two enlightening articles:</p><p><a href="https://kozyrkov.medium.com/why-businesses-fail-at-machine-learning-fbff41c4d5db">Why businesses fail at Machine Learning</a></p><p><a href="https://hbr.org/2023/10/how-ai-can-help-leaders-make-better-decisions-under-pressure">How AI can help leaders make better decisions under pressure</a>‍</p><p>Instead, we focus on two gaping holes in the current software implementation approach.</p><h3>Gaping hole 1: A very siloed Environment</h3><p>Visualizing the various groups involved in a typical AI project is interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u9CrzhtqUCBoEAnE.png" /><figcaption><em>Siloed environment in the data team</em></figcaption></figure><p>Of course, there are valid reasons for having these different roles, let alone the need for specialization. However, it is worth noting that:</p><ul><li>On a real project, the gap between the data scientists and end-users is substantial.</li><li>Each silo uses different technology stacks. It is not uncommon for data scientists to develop mainly in Python, while IT developers use JavaScript, Java, Scala, etc.</li><li>There has never been a wider variety of programming skills between and within each siloes.</li></ul><p>‍</p><h3>Gaping hole 2: Getting acceptance from the end-users / business-users</h3><p>As highlighted in a <a href="https://www.taipy.io/posts/bringing-the-end-user-into-the-ai-picture">previous article</a>, end-users seem to have disappeared from the AI landscape. It is all about data, technologies, algorithms, testing, deployment, etc. As if all AI projects will necessarily replace completely human experts. I am convinced that the future of AI in the industry lies in the hybrid collaboration between business users and AI software.</p><p>However, end-users are an integral part of AI software development. Not getting them fully involved during the development process puts you at risk of not having your software used when the system goes live.</p><p>Our strategy is to ensure that these two steps get implemented:</p><ol><li>A smooth end-user Interaction with the algorithm(s)</li><li>And an easy tracking of business-user satisfaction</li></ol><p>‍</p><h3>How to fill Gap 1?</h3><p>Some obvious directions are:</p><ol><li>To standardize as much as possible on a single programming language.</li><li>Provide an easy-to-learn/use programming experience to cater to all programming levels.</li></ol><p>Python is the ideal candidate for this. It is at the heart of the AI stack and ideal for integrating with other environments.</p><p>Many Python libraries are available and provide an easy learning curve (including low code); unfortunately, they often suffer from performance issues and lack of customization.</p><p>Let’s consider, for instance, the development of graphical Interfaces: One has the choice of using full-code libraries like Plotly Dash (or even development in Java Script) or easy-to-develop libraries like Streamlit or Gradio. However, these libraries do not scale performance-wise and will set you into a strict framework forbidding most customization.</p><p>A Python developer shouldn’t have to arbitrage so much between programming productivity and performance/customization.</p><p>We spent a lot of time on the design/implementation of our product, <a href="http://github.com/Avaiga/taipy">Taipy</a>, to go one step further by guaranteeing ease of development while providing a huge leap in performance and customization. Here are two examples of performance issues (amongst many others) solved with Taipy:‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*ZkpgZs0s4JoYsxN2.gif" /><figcaption><em>Optimized for perfomance</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*FyRWIFOD53vtkb-a.gif" /><figcaption><em>Large data support</em></figcaption></figure><p>‍</p><h3>How to fill Gap 2?</h3><p>Addressing the two salient points mentioned above is crucial:</p><ol><li>A smooth end-user Interaction with the back-end algorithm(s)</li><li>And an easy tracking of the business-user satisfaction‍</li></ol><h4>Addressing Point 1: the end-user needs to interact with the algorithm/back-end.</h4><p>For this purpose, it is essential to:</p><ul><li>Provide variables/parameters that the end-user can control through the GUI.</li><li>Allow the end-user to execute backend algorithms using these different parameter values, leading to different results.</li><li>Provide the possibility to compare these different runs and track KPI performance over time.</li></ul><p>In Taipy, we have introduced the <strong>‘scenario’ </strong>concept that addresses all of the above requirements.</p><p>A scenario consists of the execution of the algorithm/pipeline where Taipy stores all the data elements (data sources, data outputs)</p><p>Taipy’s scenario registry enables the end-user to:</p><ul><li>keep track of all of its runs,</li><li>revisit a past scenario, understand its results, scan its input data, etc.</li></ul><p>‍</p><h4>Addressing Point 2: easy tracking of the business-user satisfaction</h4><p>Another great benefit of Taipy’s Scenario function is that it reduces the gap between the end-user and the data scientists. The Taipy scenario registry is a gold mine for data scientists since they can access all end-user’s runs. In addition, the end-user can tag any of these scenarios and share them with the data scientists for examination.</p><p>This scenario feature can dramatically increase the software’s acceptance by the end-user. Unfortunately, in practice, testing AI algorithms is generally limited to a few test cases and the usage of drift detection. More is needed to guarantee a high acceptance of the software. And Taipy’s scenarios will help a lot here.‍</p><p>Here are some examples of Taipy AI applications enabling the business user to explore previously generated scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*ddYjSDuRR2URiwkR.gif" /><figcaption><em>Create a scenario in Taipy</em></figcaption></figure><h3>Conclusion</h3><p>To conclude with, <a href="http://github.com/Avaiga/taipy">Taipy </a>has proven instrumental in the success of AI projects for leading corporations, offering an efficient and user-friendly Python framework. With the launch of Taipy Designer, we continue to democratize AI development, focusing on accessibility for Data Analysts and ensuring the seamless integration of AI into business processes.</p><blockquote><em>Support us by giving us a </em><a href="https://github.com/Avaiga/taipy"><em>star⭐</em></a></blockquote><p>Visit us at <a href="https://www.datadriveninvestor.com/"><em>DataDrivenInvestor.com</em></a></p><p>Subscribe to DDIntel <a href="https://www.ddintel.com/"><em>here</em></a>.</p><p>Featured Article:</p><p><a href="https://medium.datadriveninvestor.com/accelerating-success-through-the-singapore-fund-asset-management-platform-cbd393bf0e6a">Introducing Singapore’s Fund Platform</a></p><p>Join our creator ecosystem <a href="https://join.datadriveninvestor.com/"><em>here</em></a>.</p><p>DDI Official Telegram Channel: <a href="https://t.me/+tafUp6ecEys4YjQ1">https://t.me/+tafUp6ecEys4YjQ1</a></p><p>Follow us on <a href="https://www.linkedin.com/company/data-driven-investor"><em>LinkedIn</em></a>, <a href="https://twitter.com/@DDInvestorHQ"><em>Twitter</em></a>, <a href="https://www.youtube.com/c/datadriveninvestor"><em>YouTube</em></a>, and <a href="https://www.facebook.com/datadriveninvestor"><em>Facebook</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34fd17507807" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/taipy-or-how-to-remove-major-hurdles-with-your-ai-data-projects-34fd17507807">Taipy or How to Remove Major Hurdles with Your AI/Data Projects</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taipy 3.1: A new era of visualization and data management]]></title>
            <link>https://medium.datadriveninvestor.com/taipy-3-1-a-new-era-of-visualization-and-data-management-b4f06c1c0787?source=rss-ea1c64d90586------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4f06c1c0787</guid>
            <dc:creator><![CDATA[Marine Gosselin]]></dc:creator>
            <pubDate>Wed, 20 Mar 2024 15:37:48 GMT</pubDate>
            <atom:updated>2024-03-22T07:07:41.860Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*o1eqFkvt7AJog6XY.png" /></figure><blockquote>Author: <a href="https://www.linkedin.com/in/vincent-gosselin-5011559/">Vincent Gosselin</a></blockquote><p>We are thrilled to announce the release of Taipy 3.1, a significant update that brings many new features and enhancements to our comprehensive platform.</p><p>This latest version underscores our commitment to providing robust, scalable, and intuitive functionalities that cater to the community and the enterprise needs. With Taipy 3.1, users can expect many improvements designed to enhance data visualization, integrate tightly with Python visualization libraries, and enable more efficient computing capabilities.</p><h3>Empowering the Community Edition with New Features</h3><h3>Third-Party Component Integration</h3><p>This enhancement allows users to seamlessly integrate a broad range of Python libraries into their Taipy application without waiting for specific integrations. By enabling the visualization of any html of Python objects into Taipy’s generic <em>part</em> object, users can now effortlessly incorporate tools with many Python visualization libraries like Folium, Bokeh, Altair, Matplotlib, etc.</p><p>To go in depth with this feature, the <strong><em>part </em></strong>block is used to group visual elements into a single element. This allows to show or hide them in one action and be placed as a unique element in a cell.</p><p>More technical info <a href="https://links.taipy.io/RelNotes31"><strong>here</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*FTx2c-wS_iMbOFL-4JZLUA.gif" /><figcaption><em>Third-party component integration</em></figcaption></figure><h3>Native Plotly Integration</h3><p>Further enriching the data visualization capabilities of Taipy, version 3.1 integrates Plotly Python natively. Until Taipy V3, integrating additional charts from Plotly has some complexity. Now, any Plotly chart can be embedded within a Taipy application in a single line of code while retaining the performance and interactivity of Taipy.</p><p>If we dig more in details, the control has a new property called <strong><em>figure </em></strong>that expects an instance of <em>plotly.graph_objects.Figure</em>. This class is provided by the Plotly Open Source Graphig Libary for Pyhon, so you can create all sorts of graphs in Python.</p><p>More technical info <a href="https://links.taipy.io/RelNotes31"><strong>here</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*cnnwvV24NwWeZkZp.gif" /><figcaption><em>Native Plotly Charts integration</em></figcaption></figure><h3>Elevating Enterprise Solutions with Advanced Features</h3><h3>Distributed Computing</h3><p>Recognizing the growing needs of enterprises for scalable data processing solutions, Taipy 3.1 introduces Distributed Computing capabilities.</p><p>This feature enables the distribution of computational tasks across multiple machines, significantly improving the performance of large-scale data projects. Companies can now leverage distributed computing to perform complex computation tasks more efficiently, reducing turnaround times and enhancing productivity.</p><p>If we go deeper in the technical aspect, a new job execution mode named<strong> <em>cluster mode</em></strong> is available. It enables to run the jobs on a cluster of dedicated machines in a remote, distributed and scalable environment.</p><p>More technical info <a href="https://links.taipy.io/RelNotes31"><strong>here</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/0*vc7GP3FXhRmv6JAG.gif" /><figcaption><em>Distributed Computing</em></figcaption></figure><h3>Telemetry</h3><p>To assist enterprises in maintaining the health and performance of their applications, Taipy 3.1 incorporates Telemetry features. This addition provides administrators and developers with valuable insights into application performance metrics and health indicators. By facilitating the monitoring and analysis of these metrics, Taipy aims to help enterprises proactively identify and address potential issues, ensuring smoother operations and optimal performance.</p><p>More technical info <a href="https://links.taipy.io/RelNotes31"><strong>here</strong></a>‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*Kn_kTrOn1BwCDyLA.png" /><figcaption><em>Telemetry</em></figcaption></figure><p>‍‍</p><blockquote><strong><em>And beside all this, Taipy and all its dependencies now support Python 3.12.</em></strong></blockquote><p>‍</p><h3>Conclusion</h3><p>Taipy 3.1 represents a major step forward in our mission to provide data scientists with a powerful, flexible and easy-to-use framework.</p><p>Whether you are part of the open-source community or seeking enterprise-level solutions, this release let you enhance your data projects. We are excited to see how you will leverage these new capabilities to build great pilots as well as fantastic production-ready applications.</p><p>For those interested in exploring these new features further, we encourage you to join our growing community of developers and data scientists and meet some of the on Discord.</p><p><a href="https://discord.com/invite/SJyz2VJGxV">Join us on Discord</a></p><p>Together, we can continue to innovate and make Taipy the standard framework for your Python application development needs.</p><p>‍</p><p><a href="https://github.com/Avaiga/taipy">Star on GitHub!</a></p><p>Visit us at <a href="https://www.datadriveninvestor.com/"><em>DataDrivenInvestor.com</em></a></p><p>Subscribe to DDIntel <a href="https://www.ddintel.com/"><em>here</em></a>.</p><p>Featured Article:</p><p><a href="https://medium.datadriveninvestor.com/accelerating-success-through-the-singapore-fund-asset-management-platform-cbd393bf0e6a">Introducing Singapore’s Fund Platform</a></p><p>Join our creator ecosystem <a href="https://join.datadriveninvestor.com/"><em>here</em></a>.</p><p>DDI Official Telegram Channel: <a href="https://t.me/+tafUp6ecEys4YjQ1">https://t.me/+tafUp6ecEys4YjQ1</a></p><p>Follow us on <a href="https://www.linkedin.com/company/data-driven-investor"><em>LinkedIn</em></a>, <a href="https://twitter.com/@DDInvestorHQ"><em>Twitter</em></a>, <a href="https://www.youtube.com/c/datadriveninvestor"><em>YouTube</em></a>, and <a href="https://www.facebook.com/datadriveninvestor"><em>Facebook</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4f06c1c0787" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/taipy-3-1-a-new-era-of-visualization-and-data-management-b4f06c1c0787">Taipy 3.1: A new era of visualization and data management</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bringing the end-user into the AI picture]]></title>
            <link>https://medium.datadriveninvestor.com/bringing-the-end-user-into-the-ai-picture-933a9cf2f0d4?source=rss-ea1c64d90586------2</link>
            <guid isPermaLink="false">https://medium.com/p/933a9cf2f0d4</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Marine Gosselin]]></dc:creator>
            <pubDate>Thu, 15 Feb 2024 13:53:40 GMT</pubDate>
            <atom:updated>2024-02-19T03:12:44.120Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6tofOwSEG2GF4VOGF7SPOA.png" /></figure><blockquote>Author: <a href="https://www.linkedin.com/in/vincent-gosselin-5011559/">Vincent Gosselin</a></blockquote><p>There is a ton of information these days on every single phase involved in building AI algorithms, and this is great!</p><p>This covers loading/preparing data, feature engineering, training, testing, hyper-parameterization, validation, explainability, MLOps, and deployment.</p><h3>Overlooking End-Users in AI Applications</h3><blockquote>At the same time, I am puzzled to see how little is mentioned about the “end-user”: the end-user being a business person with no AI background interacting with the software.</blockquote><blockquote>Even if AI has led to many “automated” AI applications (for instance, autonomous vehicles, trading bots, etc), most companies need end-users to “collaborate”/interact with an AI engine.</blockquote><p>Let’s take two examples:</p><ol><li><a href="https://www.taipy.io/testimonials/success-story-sales-forecast">McDonald’s Store Sales Forecast</a></li><li>A two-month Cash Flow Prediction for a large Franchised brand.</li></ol><p><strong>In Example 1,</strong> a McDonald’s store manager connects to the new forecasting software. Through an ergonomic GUI, she/he can generate next week’s sales forecast (created by the AI engine). Then, she/he just discovered 5 minutes ago that a competitor across the road is running a new promotion today. She/He may then opt to lower the generated forecast by 10% during peak hours. Here, the end-user needs to modify the output of the forecast engine.</p><p><strong>In Example 2,</strong> the company treasurer wants to run the Cash Flow Prediction for the next two months. However, he wants to play with different inflation values and evaluate the impact on the forecast. Here, the end-user wants to control an input parameter (the inflation rate) to the AI Engine.</p><p>There are countless other examples where end-users need to modify an AI engine’s input or output. This is an integral part of the Decision Process.</p><h3>Taipy’s Capabilities to enhance end-user interaction with AI</h3><p>To address these situations, we defined (as part of the <a href="https://github.com/Avaiga/taipy">Taipy </a>open source team) the concept of “scenario” and “data nodes”. A scenario is nothing more than the execution of your algorithm (pipeline) given a set of input information (input data nodes).</p><p>We have also implemented three essential capabilities:</p><h3>1. Data Nodes</h3><p>Ability to model pipelines as a sequence of Python tasks as well as Data Nodes (anything that can be an input or an output of a Python task). A data node can connect to any data format (SQL, NoSQL, CSV, JSON, etc) or a parameter (a Python object, i.e., A date entered by the end-user through the graphical interface).</p><h3>2. Scenarios</h3><p>Ability to record each pipeline execution (inside a registry). We call such execution a ‘scenario’.</p><h3>3. Scenario comparison</h3><p>Ability to retrieve past/registered scenarios, compare them, track them, etc.</p><p>We decided to provide two options for defining your pipeline in <a href="https://github.com/Avaiga/taipy">Taipy</a>: Programmatically or using a Visual Code Graph Editor.</p><p>‍</p><h3>Let’s take an example</h3><h3>1. Create a pipeline</h3><p>Let’s take a straightforward pipeline case with:</p><p>- <strong>A single task:</strong> “predict”, calling the inference of an AI engine</p><p><strong>- 2 input Data Nodes:</strong> ‘historical_temperature” and “date_to_forecast”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*b31hiO4ynbDLRrXWEFF4aQ.png" /><figcaption><em>A single task pipeline with 2 data nodes</em></figcaption></figure><p>‍</p><p>To create this pipeline, with <a href="https://github.com/Avaiga/taipy">Taipy</a>, we have two options:</p><p><strong>Option 1: Programmatical Configuration</strong></p><p>We can dive into Python code. This script creates a <em>scenario_cfg</em> object:</p><pre>from taipy import Config<br># Configuration of Data Nodes<br>historical_temperature_cfg = Config.configure_data_node(&quot;historical_temperature&quot;)<br>date_to_forecast_cfg = Config.configure_data_node(&quot;date_to_forecast&quot;)<br>predictions_cfg = Config.configure_data_node(&quot;predictions&quot;)<br># Configuration of tasks<br>predict_cfg = Config.configure_task(id=&quot;predict&quot;,<br>                                    function=predict,<br>                                    input=[historical_temperature_cfg, date_to_forecast_cfg],<br>                                    output=predictions_cfg)<br># Configuration of a scenario configuration<br>scenario_cfg = Config.configure_scenario(id=&quot;my_scenario&quot;, task_configs=[predict_cfg])‍</pre><p><strong>Option 2: Graphical Editor Configuration</strong></p><p>Or, we can use <a href="https://docs.taipy.io/en/latest/manuals/studio/">Taipy Studio</a>, the Pipeline/DAG Graphical Editor that enhances pipelines creation. (It’s a <a href="https://code.visualstudio.com/">VS Code extension</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*b31hiO4ynbDLRrXWEFF4aQ.png" /><figcaption><em>Taipy Studio, the Pipeline/DAG Graphical Editor</em></figcaption></figure><p>The <em>scenario_cfg</em> object is then created by loading the previous diagram and saved as a TOML file.</p><pre>Config.load(&#39;config.toml&#39;)<br># my_scenario is the id of the scenario configured<br>scenario_cfg = Config.scenarios[&#39;my_scenario&#39;]</pre><p><a href="https://docs.taipy.io/en/latest/manuals/studio/">Discover Taipy Studio</a></p><p>‍</p><h3>2. Execute different scenarios</h3><p>Scenarios are just instances of the previous pipeline configuration.</p><p>Here:</p><ol><li>We create a scenario (an instance of the pipeline configuration above)</li><li>2. We initialize its input data nodes</li><li>3. We execute it (<em>tp.submit()</em>)</li></ol><pre>import taipy as tp<br><br># Run of the Taipy Core service<br>tp.Core().run()<br><br># Creation of the scenario<br>scenario = tp.create_scenario(scenario_cfg)<br><br># Initialize the 2 input data nodes<br>scenario.historical_temperature.write(data)<br>scenario.date_to_forecast.write(dt.datetime.now())<br><br># execution of the scenario<br>tp.submit(scenario)<br><br>print(&quot;Publish the predictions&quot;, scenario.predictions.read())</pre><p>Note that behind the screen, the execution of a given scenario is registered, i.e., an automatic storage of information related to each data node used at the time of execution.</p><p>‍</p><h3>Benefits</h3><p>This relatively “simple” scenario management process defined in this article allows for:</p><h3>1. A rich set of user functionalities such as:</h3><ul><li>Easy Retrieval of all scenarios over a given period and their associated input/output data nodes allows easy data lineage.</li><li>Comparing two or more scenarios based on some KPIs: the value of a given data node.</li><li>Tracking over time a given KPI</li><li>Re-executing a past scenario with new values (can change the value of a given data node)</li></ul><h3>2. Full pipeline Versioning: Essential for quality Project management</h3><p>Overall pipeline versioning is badly needed when new data nodes/sources are introduced or a new version of a given Python code (avoiding incompatibilities with previously run scenarios).</p><h3>3. Narrowing the gap between Data Scientists/Developers &amp; End-users</h3><p>By providing access to the entire repository of end-user scenarios, data scientists and Python devs can better understand how end-users use the software.</p><p>‍</p><h3>And to go further</h3><p>To help this process, we found it helpful to provide specific graphical objects to explore past scenarios visually, display their input and output data nodes, modify them, re-execute scenarios, etc.</p><p>For this purpose, we extended <a href="https://github.com/Avaiga/taipy">Taipy’s </a>graphical library to provide a new set of graphical components for Scenario visualization.</p><p>Here’s an example of such a scenario ‘navigator’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*K_0L3WaV1udlJ84e.png" /><figcaption><em>Scenario Navigator</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y1Q9xu4I4iXezuq8.png" /><figcaption><em>Scenario Navigator</em></figcaption></figure><h3>Conclusion</h3><p>This is our interpretation of scenario management. We hope such an article will trigger more interest and discussion on this crucial topic and lead to better AI software and, ultimately, better decisions.</p><blockquote>Support us by giving us a <a href="https://github.com/Avaiga/taipy">star⭐</a></blockquote><p>Visit us at <a href="https://www.datadriveninvestor.com/"><em>DataDrivenInvestor.com</em></a></p><p>Subscribe to DDIntel <a href="https://www.ddintel.com/"><em>here</em></a>.</p><p>Have a unique story to share? Submit to DDIntel <a href="https://datadriveninvestor.com/ddintelsubmission"><em>here</em></a>.</p><p>Join our creator ecosystem <a href="https://join.datadriveninvestor.com/"><em>here</em></a>.</p><p><a href="https://ddintel.datadriveninvestor.com/"><em>DDIntel</em> </a>captures the more notable pieces from our <a href="https://www.datadriveninvestor.com/"><em>main site</em></a> and our popular <a href="https://medium.datadriveninvestor.com/"><em>DDI Medium publication</em></a>. Check us out for more insightful work from our community.</p><p>DDI Official Telegram Channel: <a href="https://t.me/+tafUp6ecEys4YjQ1">https://t.me/+tafUp6ecEys4YjQ1</a></p><p>Follow us on <a href="https://www.linkedin.com/company/data-driven-investor"><em>LinkedIn</em></a>, <a href="https://twitter.com/@DDInvestorHQ"><em>Twitter</em></a>, <a href="https://www.youtube.com/c/datadriveninvestor"><em>YouTube</em></a>, and <a href="https://www.facebook.com/datadriveninvestor"><em>Facebook</em></a>.‍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=933a9cf2f0d4" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/bringing-the-end-user-into-the-ai-picture-933a9cf2f0d4">Bringing the end-user into the AI picture</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing Python GUIs with Augmented Markdown]]></title>
            <link>https://medium.datadriveninvestor.com/enhancing-python-guis-with-augmented-markdown-532b94fa784b?source=rss-ea1c64d90586------2</link>
            <guid isPermaLink="false">https://medium.com/p/532b94fa784b</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[taipy]]></category>
            <category><![CDATA[markdown]]></category>
            <category><![CDATA[gui]]></category>
            <dc:creator><![CDATA[Marine Gosselin]]></dc:creator>
            <pubDate>Tue, 23 Jan 2024 18:16:50 GMT</pubDate>
            <atom:updated>2024-02-19T03:13:20.201Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nVqYOxDhVmkHWPQDODtXqQ.png" /></figure><blockquote><em>Author: </em><a href="https://www.linkedin.com/in/vincent-gosselin-5011559/"><em>V</em>incent Gosselin</a></blockquote><p>In the past few years, several Python packages have proposed Python API to build web-based interfaces such as:</p><ul><li><a href="https://dash.plotly.com/minimal-app">Plotly Dash</a>,</li><li><a href="https://docs.streamlit.io/library/api-reference">Streamlit</a>,</li><li>And more recently <a href="https://docs.taipy.io/en/latest/manuals/gui/page_builder/">Taipy</a>,</li></ul><p>However, one of the most underrated work has been with the creation by the Taipy R&amp;D team of an alternative API: an <strong>Augmented Markdown API</strong> for Python developers.</p><p><strong>Markdown</strong> is one of the most used markup languages: starting from a simple text document, Markdown allows the generation of HTML pages with high presentation quality, immediately deployable on a network. For those of you not familiar with the markdown language, have a look at <a href="https://www.markdownguide.org/basic-syntax/"><em>https://www.markdownguide.org/basic-syntax/</em></a><em>.</em></p><p>Based on the work of Dr. Neil Bruce [1], the Taipy team has extended the very simple syntax of Markdown by allowing the writer to add tags that would trigger the generation of a graphical interface element directly in their content.</p><p>In his 2020 seminal article, “<em>A Framework for Dynamic Data-Driven User Interfaces</em>”[2], Mirovic proposes a model for controlling an application based on its underlying data model. However, a significant disadvantage of this approach is that it requires programmers to explicitly define the data sources they wish to use to construct their interface.</p><p>The proposed solution involves directly connecting graphical components to application data. Programmers can simply use the name of the variable they wish to be reflected in the GUI during the development of their Markdown source. For instance, if a variable ‘value’ appears in the code, adding the tag <em>&lt;{value}&gt;</em> in the text itself will display it. To make the variable editable by the end user, it can be contained within an editable text area: <em>&lt;{value}|text_input&gt;</em>.</p><p>In the graphical interface development stage, programmers don’t need to worry about the layout of these elements relative to each other. The conversion from Markdown to HTML ensures that elements are appropriately placed within the surrounding text flow.</p><p>This approach does not require Python developers/Data scientists to learn new tools. They can create a text page, adding formatting tags and interface elements.</p><p>The next steps consisted of providing all types of graphical elements that users want in their application, ensuring each graphical component can graphically represent the connected data, synchronizing the GUI with the application managing the variables, enabling experienced GUI developers to refine the graphical representation of components, and adapting the generated GUIs to usability and accessibility needs.</p><h3>Web-Based User Interfaces:</h3><p>The choice was made to deploy interfaces through web browsers for portability and adaptation to various situations. This involved proposing a client-server architecture where the server hosts the main application (data and algorithms) and the client is a simple web browser connecting to the server using standard market protocols (HTTP, WebSocket).</p><h3>Data Transformation and User Interface Generation:</h3><p>The project involved transforming Python data types into Markdown-like representations based on client-side component types (text, buttons, selectors, charts, etc.). Other syntaxes like XUL or XAML could have been selected but the major drawback of these syntaxes is the need for detailed knowledge of graphical representation programming interfaces to create a functioning user interface.</p><p>Here are the different issues that had to be implemented to transform data on the server side into a representation on the Web client:</p><h3><strong>1. Data Transformation and Interface Representation:</strong></h3><p>The project focused on automatically converting server-side data into a format suitable for web client representation. This involved considering various data types and corresponding interface elements, such as text in a button or a numeric value in a slider.</p><h3><strong>2. Data Type to Representation Mapping</strong></h3><p>The initial work was with basic Python data types (Boolean, integer, float, string, lists, dictionaries, etc.) and transformed these into representations based on the type of component desired on the client side, like editable text, buttons, selectors, etc.</p><h3><strong>3. User Interface Design Approach</strong></h3><p>The goal was to enable users with minimal technical skills to describe how these elements would be organized on a Markdown page. This enhanced/augmented Markdown needed to integrate control elements within the markdown text, which would be transformed into active graphical components on the client side.</p><h3><strong>4. Communication Protocol</strong></h3><p>To establish a connection between the server (hosting the application) and the client (displaying the control elements), they opted for WebSocket (after having evaluated other protocols such as <em>RPC</em>, <em>Apache Arrow Flight)</em>. This protocol is lightweight, efficient, and requires minimal configuration. It allows for the serialization of necessary data structures, supported on both the server side (Python) and the client side (JavaScript).</p><h3><strong>5. User Actions and Data Transmission</strong></h3><p>WebSocket converts user actions into messages, which are sent to the application for processing changes in application variables. Conversely, changes in application data are transmitted back to the client, impacting the graphical components.</p><h3><strong>6. Specific Focus on complex data</strong></h3><p>A key focus was on transferring data from the server to the client, especially in complex cases like maps or graphs, without overwhelming network and processing capacities. Solutions were developed to manage large volumes of data in complex graphical objects, ensuring efficient data transfer and minimizing user wait times. The goal was to transmit only the displayable data, using intelligent sampling techniques to avoid network and process saturation.</p><p>Here’s the result with a sample code written using Taipy augmented markdown syntax:</p><pre>from math import cos, exp<br>value = 10<br>page = &quot;&quot;&quot;<br>Markdown<br># Taipy *Demo*<br>Value: &lt;|{value*10}|text|&gt;<br>&lt;|{value}|slider|&gt;<br>&lt;|{compute_data(value)}|chart|&gt;<br>&quot;&quot;&quot;<br><br><br>def compute_data(decay:int)-&gt;list:<br>      return [cos(i/6) * exp(-i*decay/600) for i in range(100)]<br><br><br>Gui(page).run(use_reloader=True, port=5002)p</pre><p>One can notice the syntax &lt;|<em>element1</em>|<em>element2</em>|…|&gt;</p><p><em>element1 </em>is a Python object, <em>element2 </em>is the type of graphical representation associated with this object.</p><p>Example: <em>&lt;|{value}|slider|&gt;</em> displays a slider associated with the Python variable value.</p><p>The execution of that Python script is given below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NzfmcTMvrXQ1dcEm" /></figure><p><em>References:</em></p><p><em>[1] — Prototyping with markdown. Dr. Neil Bruce, 2017.</em></p><p><em>[2] — A Framework for Dynamic Data-Driven User Interfaces. M. Mirović, 2020.</em></p><p>Visit us at <a href="https://www.datadriveninvestor.com/"><em>DataDrivenInvestor.com</em></a></p><p>Subscribe to DDIntel <a href="https://www.ddintel.com/"><em>here</em></a>.</p><p>Have a unique story to share? Submit to DDIntel <a href="https://datadriveninvestor.com/ddintelsubmission"><em>here</em></a>.</p><p>Join our creator ecosystem <a href="https://join.datadriveninvestor.com/"><em>here</em></a>.</p><p><a href="https://ddintel.datadriveninvestor.com/"><em>DDIntel</em> </a>captures the more notable pieces from our <a href="https://www.datadriveninvestor.com/"><em>main site</em></a> and our popular <a href="https://medium.datadriveninvestor.com/"><em>DDI Medium publication</em></a>. Check us out for more insightful work from our community.</p><p>DDI Official Telegram Channel: <a href="https://t.me/+tafUp6ecEys4YjQ1">https://t.me/+tafUp6ecEys4YjQ1</a></p><p>Follow us on <a href="https://www.linkedin.com/company/data-driven-investor"><em>LinkedIn</em></a>, <a href="https://twitter.com/@DDInvestorHQ"><em>Twitter</em></a>, <a href="https://www.youtube.com/c/datadriveninvestor"><em>YouTube</em></a>, and <a href="https://www.facebook.com/datadriveninvestor"><em>Facebook</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=532b94fa784b" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/enhancing-python-guis-with-augmented-markdown-532b94fa784b">Enhancing Python GUIs with Augmented Markdown</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a crash-free solution to plotting Big data in Python]]></title>
            <link>https://medium.datadriveninvestor.com/building-a-crash-free-solution-to-plotting-big-data-in-python-704715bef7c6?source=rss-ea1c64d90586------2</link>
            <guid isPermaLink="false">https://medium.com/p/704715bef7c6</guid>
            <dc:creator><![CDATA[Marine Gosselin]]></dc:creator>
            <pubDate>Tue, 12 Dec 2023 09:12:46 GMT</pubDate>
            <atom:updated>2023-12-13T03:25:28.651Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YcyAjNdCR-3DWkiAWA3vA.png" /></figure><blockquote>Author: <a href="https://www.linkedin.com/in/alexandre-sajus/">Alexandre Sajus</a></blockquote><p>Our focus this year with the R&amp;D team was to minimize the volume of data transiting between the application and the GUI client without losing on the information.</p><p>When we talked about Data we are referring to large Tabular data with plenty of columns and even more rows. If we consider a table (dataframe, array, etc) with just 20 columns and 500K rows, generating a graphical view for such table will require over 1 minute on a 10MB/s network!</p><pre>10 Mb/s x 8 (bits) x 8 (bytes) * 20 (columns) * 500,000 /<br>10,000,000 (network throughput)<br><br>=  64 sec</pre><p>If we manage to reduce “smartly” the number of points that define the shape of the plot/curve, we will get overcome:</p><ul><li>The <strong>network bandwidth</strong> (see above)</li><li>The <strong>memory used</strong> on the client side</li><li>A more <strong>meaningful visual</strong> (client side) since the plot will involve a much lower number of data points.</li><li>A much better <strong>user experience</strong>: when the end-user clicks on a point to perform some action, the graphical component has to seek which points amongst the whole dataset have been selected. With a reduced number of points, performance will improve drastically.</li></ul><p>This work is completely disconnected from data transformation, such as compression algorithms. It is known that HTTP/1.1 already supports data compression (<em>see the </em><a href="https://www.ietf.org/rfc/rfc2616.txt)"><em>Internet Engineering Task Force</em></a>).</p><h3>First level: dealing with curves (2D)</h3><h3><strong>The basic “algorithm”</strong></h3><p>The first effort was to transform data (with hundreds of thousands of points or more) on the application side to a reduced form that can be plotted as a curve visually equivalent to the full data set. Such reduced form should not exceed the maximum resolution of the screen/frame (usually on the horizontal axis).</p><p>The process of “reducing” a dataset by eliminating “non-significant” points is generally referred to as “<strong><em>decimation</em></strong>” or “<strong><em>downsampling</em></strong>” (or even “<strong><em>subsampling</em></strong>”).</p><p><strong>Important</strong>: This implementation must allow the end-user to select (graphically) a different subset of the displayed curve with an automatic re-run of the “decimator algorithm”. This will allow the optimal” display of the data whatever zoom level is applied by the end-user.</p><p>We evaluated three different algorithms:</p><ul><li>The <em>Min-Max</em> algorithm</li><li>The <em>LTTB </em>algorithm</li><li>The <em>Ramer-Douglas-Peuker</em> algorithm</li></ul><h3>Min-Max algorithm</h3><p>Let NOP be the desired number of points to be represented on the client side.</p><p>The Min-Max algorithm divides one of the dimensions into as many segments as the number of points (NOP).</p><p>For each segment only the 2 extreme points (on the second axis) of the original dataset are kept. Only the extreme values are kept.</p><p><strong>Performance is excellent.</strong></p><h3>LTTB Algorithm</h3><p>This algorithm is also referred to as “Largest Triangle Three Buckets”.</p><p>This algorithm forms triangles between adjacent points to decide the relative importance of these points. This is a technique used often in cartography. Several LTTB implementations are available in Python.</p><p><strong>Performance of this downsampling algorithm is also excellent.</strong></p><h3>The Ramer-Douglas-Peucker Algorithm</h3><p>This algorithm uses a completely different approach. It seeks “important” points in the initial/large datasets. These important points are points that if removed, do modify drastically the shape of the curve. Another way to put it is: this algorithm removes all the points that least modify the shape of the curve.</p><p>More information can be found in the seminal paper:</p><ul><li><em>“The Douglas-Peucker Algorithm for Line Simplification“. M. Visvalingam &amp; J. D. Whyatt, 1990.</em></li></ul><p>Then an improved version of the algorithm:</p><ul><li><em>“Line generalization by repeated elimination of points“. M. Visvalingam &amp; J. Whyatt, 1993.</em></li></ul><p><strong>Performance is not as good as the previous ones, but the quality of the results (as demonstrated below) is much better.</strong></p><h3>Second level: dealing with a cloud of points (3D or more)</h3><p>The previous algorithms are well suited for 2D curves but are not satisfactory to higher dimension visuals: if several data points of the original dataset get projected on the same space, they would simply be removed if using the previous algorithms. Here, the density of the points needs to be represented. We developed a specific algorithm using the following approach:</p><ul><li>We divide the representation space (client side) into a mesh space.</li><li>We minimize the number of points projected in the same cell (of the mesh)</li><li>We ensure that cells with a single point are preserved.</li></ul><h3>Results</h3><p>Presenting here quantitative results, in terms of time or memory saved, when applying adaptive optimization algorithms is not very useful. Indeed, the achieved performance improvements are closely related to three independent factors: the computational power of the application server and its available memory, the network bandwidth connecting the server to the client, and the client-side itself, where the type of browser also comes into play.</p><p>On the other hand, a commented visualization of the results obtained can be interesting. Here is a typical curve in front of which a data analyst should make decisions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*MfX1mgSusTqAG-h7OHfO3Q.png" /><figcaption>Initial Curve</figcaption></figure><p>This curve is the result of sampling an anonymous dataset and contains more than 15,000 points. Its display is performed by a thin line connecting markers at each point representing a sample. We chose this dataset because it contains several types of progressions that will interest us in judging the results: an area where the data progresses slowly, more abrupt variations, and local disturbances. All points are represented in the above curve, and we will apply our algorithms to these data to judge the visual quality of decimation — how satisfactory the result is and at what cost.</p><p>For each of the selected algorithms, we decimated the initial dataset by setting the number of output points to:</p><ul><li>500, to visually compare the shapes of the curves and check the approximation’s satisfaction. This number of curve definition points seems consistent with the intended use, occupying between half and one-third of the common horizontal screen resolutions.</li><li>100, to visually account for how the algorithm behaves in different regions of the original curve. The degradation is considerable and unacceptable in the context of an application.</li></ul><h3>Min-Max Algorithm</h3><p>Here is the result of executing this algorithm on the initial dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*wZtUBhvAI6tprkhoIgqfnQ.png" /><figcaption>500 points</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*GVBeHWn0tHpHvWD6PXbxKA.png" /><figcaption>100 points</figcaption></figure><p>We can observe that the overall appearance of the curve is well preserved, as we hoped. An obvious drawback is visible on the low-quality curve: the uniform segmentation of the axis causes a kind of waste of output points at the beginning of the curve, where little variation is visible.</p><h3>LTTB Algorithm</h3><p>If we execute this algorithm on our dataset, we obtain the following curves:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*-D3IYwUOtj-vqe5lUVqv4A.png" /><figcaption>500 points</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*LCv8MEIBOM4zfQ2sHDszKQ.png" /><figcaption>100 points</figcaption></figure><p>We can observe (on the low-quality curve) the same problem on the left part of the curve. This is not surprising since the surface of the evaluated triangles will increase with the abscisse spacing, retaining potentially non-significant points. On the other hand, we can see greater precision in the part where values ​​increase rapidly (first peak): both local peaks are well preserved whereas the Min-Max had eliminated one of the two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/0*0rJvlYoIfrcfDqzV.png" /><figcaption>500 points</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/0*lVY_SJ5HJzqWFncW.png" /><figcaption>100 points</figcaption></figure><h3>Ramer–Douglas–Peucker Algorithm</h3><p>The third algorithm gives the following curves:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/0*g7sOI26H1ujV9O8w.png" /><figcaption>500 points</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/0*L2h3GUGJiu3w74Fx.png" /><figcaption>100 points</figcaption></figure><p>This time, it is clear that the left part of the curve (with its low variability) is approximated by one or two segments, which seems optimal. This allows “saving” additional points to better define the rest of the produced curve. The performance of this algorithm is significantly worse than for the two algorithms described above but potentially more ‘precise’ concerning the shape of the curve. Unlike the two previous algorithms, this algorithm in its original form does not start from the target number of points to obtain as output. It uses a threshold value (‘epsilon’) beyond which we consider that a segment deviates angularly too much from the previous one, causing the selection of its destination point as ‘significant.’</p><p>A modified form of this algorithm is needed if one wants to impose a target number of points (like the other algorithms). A pre-processing phase is needed, which is more costly.</p><h3>Performance</h3><p>As we have already mentioned, providing absolute performance values would not be very useful, as the execution conditions of our algorithms can vary drastically. However, relative performance data can be useful. Here they are:</p><ul><li><strong>Min-Max</strong>: 1 (reference value)</li><li><strong>LTTB</strong>: 10 x</li><li><strong>Ramer–Douglas–Peucker</strong> (using the ‘epsilon’ threshold): 20 x</li><li><strong>Ramer–Douglas–Peucker</strong> (using a fixed number of points): 800 x</li></ul><h3>‍Conclusion</h3><p>Our <em>Community Edition </em>offers<em> </em>the possibility to apply or not a decimation algorithm. A developer can choose which algorithm to use and with what parameters. If this algorithm is to impact the application’s performance too much, it is always possible to fine-tune these parameters.</p><p>In the case where the end-user zooms in or out or scrolls the curve, the server must calculate the new data entirely represented. It is important then that the developer understands the consequences of his choices in terms of:</p><ul><li>manipulated data volume</li><li>the parameters of each decimation algorithm.</li></ul><blockquote><strong><em>Check out and give a </em></strong><a href="https://github.com/Avaiga/taipy"><strong><em>star</em></strong><em>⭐</em><strong><em>to Taipy </em></strong></a><strong><em>!</em></strong></blockquote><p>Visit us at <a href="https://www.datadriveninvestor.com/"><em>DataDrivenInvestor.com</em></a></p><p>Subscribe to DDIntel <a href="https://www.ddintel.com/"><em>here</em></a>.</p><p>Have a unique story to share? Submit to DDIntel <a href="https://datadriveninvestor.com/ddintelsubmission"><em>here</em></a>.</p><p>Join our creator ecosystem <a href="https://join.datadriveninvestor.com/"><em>here</em></a>.</p><p><a href="https://ddintel.datadriveninvestor.com/"><em>DDIntel</em> </a>captures the more notable pieces from our <a href="https://www.datadriveninvestor.com/"><em>main site</em></a> and our popular <a href="https://medium.datadriveninvestor.com/"><em>DDI Medium publication</em></a>. Check us out for more insightful work from our community.</p><p>DDI Official Telegram Channel: <a href="https://t.me/+tafUp6ecEys4YjQ1">https://t.me/+tafUp6ecEys4YjQ1</a></p><p>Follow us on <a href="https://www.linkedin.com/company/data-driven-investor"><em>LinkedIn</em></a>, <a href="https://twitter.com/@DDInvestorHQ"><em>Twitter</em></a>, <a href="https://www.youtube.com/c/datadriveninvestor"><em>YouTube</em></a>, and <a href="https://www.facebook.com/datadriveninvestor"><em>Facebook</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=704715bef7c6" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/building-a-crash-free-solution-to-plotting-big-data-in-python-704715bef7c6">Building a crash-free solution to plotting Big data in Python</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to master Big Data pipelines with PySpark and Taipy]]></title>
            <link>https://medium.datadriveninvestor.com/how-to-master-big-data-pipelines-with-pyspark-and-taipy-a594ce47070c?source=rss-ea1c64d90586------2</link>
            <guid isPermaLink="false">https://medium.com/p/a594ce47070c</guid>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Marine Gosselin]]></dc:creator>
            <pubDate>Wed, 29 Nov 2023 15:21:51 GMT</pubDate>
            <atom:updated>2023-11-30T09:25:53.158Z</atom:updated>
            <content:encoded><![CDATA[<p>Master Big Data pipelines with the integration of Taipy and PySpark, coupling <strong>smart job execution</strong> with your <strong>big data processing needs.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xEE3UCWbdhDe8Bh79s_Mug.png" /></figure><h3>Using PySpark with Taipy</h3><p>Taipy is a powerful <strong>workflow orchestration tool</strong> with an easy-to-use framework to apply to your existing data applications with little effort. Taipy is built on a solid foundation of concepts — <strong>Scenarios, Tasks and Data</strong> <strong>Nodes</strong> — which are robust in allowing developers to easily model their pipelines, even when using 3rd party packages without explicit support.</p><blockquote>If you’re already familiar with PySpark and Taipy, you can skip ahead to “<em>2. The Taipy configuration (config.py)</em>”. That section dives right into the nitty-gritty of defining a function for a Taipy task to run a PySpark application. Otherwise, read on!</blockquote><p>This article will employ a simple example to demonstrate how we can integrate <strong>PySpark</strong> with <strong>Taipy</strong> to couple your <strong>big data processing needs with smart job execution</strong>.</p><blockquote><strong>It would be awesome if you could add a </strong><a href="https://github.com/Avaiga/taipy"><strong>star</strong>⭐<strong>to our repository</strong></a><strong>! It helps us grow the community and create content ❤</strong></blockquote><h3>A Simple Example: <em>palmerpenguins</em></h3><p>Let’s use the <a href="https://allisonhorst.github.io/palmerpenguins/"><em>palmerpenguins</em></a> dataset as an example:</p><pre>&gt;&gt;&gt; penguin_df<br>┌───────┬─────────┬───────────┬────────────────┬───────────────┬───────────────────┬─────────────┬────────┬──────┐<br>│ index │ species │  island   │ bill_length_mm │ bill_depth_mm │ flipper_length_mm │ body_mass_g │  sex   │ year │<br>├───────┼─────────┼───────────┼────────────────┼───────────────┼───────────────────┼─────────────┼────────┼──────┤<br>│     0 │ Adelie  │ Torgersen │ 39.1           │ 18.7          │ 181.0             │ 3750.0      │ male   │ 2007 │<br>│     1 │ Adelie  │ Torgersen │ 39.5           │ 17.4          │ 186.0             │ 3800.0      │ female │ 2007 │<br>│     2 │ Adelie  │ Torgersen │ 40.3           │ 18.0          │ 195.0             │ 3250.0      │ female │ 2007 │<br>│     3 │ Adelie  │ Torgersen │ NaN            │ NaN           │ NaN               │ NaN         │ NaN    │ 2007 │<br>│     4 │ Adelie  │ Torgersen │ 36.7           │ 19.3          │ 193.0             │ 3450.0      │ female │ 2007 │<br>│   ... │ ...     │ ...       │ ...            │ ...           │ ...               │ ...         │ ...    │  ... │<br>└───────┴─────────┴───────────┴────────────────┴───────────────┴───────────────────┴─────────────┴────────┴──────┘</pre><p>This dataset only contains 344 records — hardly a dataset which requires Spark for processing. However, this dataset is accessible, and <strong>its size is not relevant for demonstrating the integration of Spark with Taipy</strong>. You may duplicate the data as many times as you need if you must test this with a larger dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*oAJIIGgAX9S7U9Las8a8EA.png" /><figcaption>The DAG of our simple penguin application</figcaption></figure><p>We’ll design a workflow which performs <strong>two main tasks</strong>:</p><p><strong>1- Spark task (spark_process):</strong></p><ul><li>Load the data;</li><li>Group the data by “<em>species</em>”, “<em>island</em>” and “<em>sex</em>”;</li><li>Find the mean of the other columns (”<em>bill_length_mm</em>”, “<em>bill_depth_mm</em>”, “<em>flipper_length_mm</em>”, “<em>body_mass_g</em>”);</li><li>Save the data.</li></ul><p><strong>2- Python task (<em>filter</em>):</strong></p><ul><li>Load the output data saved previously by the Spark task;</li><li>Given a “<em>species</em>”, “<em>island</em>” and “<em>sex</em>”, return the aggregated values.</li></ul><p>Our little project will comprise of 4 files:</p><pre>app/<br>├─ penguin_spark_app.py  # the spark application<br>├─ config.py  # the configuration for our taipy workflow<br>├─ main.py  # the main script (including our application gui)<br>├─ penguins.csv  # the data as downloaded from the palmerpenguins git repo</pre><p>You can find the contents of each file (other than <em>penguins.csv</em> which you can get from <a href="https://github.com/allisonhorst/palmerpenguins/blob/main/inst/extdata/penguins.csv">palmerpenguins repository</a>) in code blocks within this article.</p><h3>1. The Spark Application (penguin_spark_app.py)</h3><p>Normally, we run PySpark tasks with the spark-submit command line utility. You can read more about the <em>what</em> and the <em>why</em> of submitting Spark jobs in this way in their own documentation <a href="https://spark.apache.org/docs/latest/submitting-applications.html">here</a>.</p><p>When using Taipy for our workflow orchestration, we can continue doing the same thing. The only difference is that instead of running a command in the command line, we have our workflow pipeline spawn a <a href="https://docs.python.org/3/library/subprocess.html">subprocess</a> which runs the Spark application using spark-submit.</p><p>Before getting into that, let’s first <strong>take a look at our Spark application</strong>. Simply glance through the code, then <strong>continue reading on for a brief explanation</strong> on what this script does:</p><pre>### app/penguin_spark_app.py<br>import argparse<br>import os<br>import sys<br><br>parser = argparse.ArgumentParser()<br>parser.add_argument(&quot;--input-csv-path&quot;, required=True, help=&quot;Path to the input penguin CSV file.&quot;)<br>parser.add_argument(&quot;--output-csv-path&quot;, required=True, help=&quot;Path to save the output CSV file.&quot;)<br>args = parser.parse_args()<br><br>import pyspark.pandas as ps<br>from pyspark.sql import SparkSession<br><br><br>def read_penguin_df(csv_path: str):<br>    penguin_df = ps.read_csv(csv_path)<br>    return penguin_df<br><br><br>def clean(df: ps.DataFrame) -&gt; ps.DataFrame:<br>    return df[df.sex.isin([&quot;male&quot;, &quot;female&quot;])].dropna()<br><br><br>def process(df: ps.DataFrame) -&gt; ps.DataFrame:<br>    &quot;&quot;&quot;The mean of measured penguin values, grouped by island and sex.&quot;&quot;&quot;<br><br>    mean_df = df.groupby(by=[&quot;species&quot;, &quot;island&quot;, &quot;sex&quot;]).agg(&quot;mean&quot;).drop(columns=&quot;year&quot;).reset_index()<br>    return mean_df<br><br><br>if __name__ == &quot;__main__&quot;:<br>    spark = SparkSession.builder.appName(&quot;Mean Penguin&quot;).getOrCreate()<br><br>    penguin_df = read_penguin_df(args.input_csv_path)<br>    cleaned_penguin_df = clean(penguin_df)<br>    processed_penguin_df = process(cleaned_penguin_df)<br>    processed_penguin_df.to_pandas().to_csv(args.output_csv_path, index=False)<br><br>    sys.exit(os.EX_OK)</pre><p>We can submit this Spark application for execution by entering a command into the terminal like:</p><pre>spark-submit --master local[8] app/penguin_spark_app.py \<br>--input-csv-path app/penguins.csv \<br>--output-csv-path app/output.csv</pre><p>Which would do the following:</p><ol><li>Submits the penguin_spark_app.py application for local execution on 8 CPU cores;</li><li>Loads data from the app/penguins.csv CSV file;</li><li>Groups by “<em>species</em>”, “<em>island</em>” and “<em>sex</em>”, then aggregates the remaining columns by mean;</li><li>Saves the resultant DataFrame to app/output.csv.</li></ol><p>Thereafter, the contents of <em>app/output.csv</em> should be exactly as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*faQLBg7UrbHYqe6M8M8nqQ.png" /></figure><p>Also, note that we have coded the <strong>Spark application to receive 2 command line parameters</strong>:</p><ol><li><em>— input-csv-path</em> : Path to the input penguin CSV file; and</li><li><em>— output-csv-path</em> : Path to save the output CSV file after processing by the Spark app.</li></ol><h3>2. The Taipy configuration (config.py)</h3><p>At this point, we have our penguin_spark_app.py PySpark application and need to <strong>create a Taipy task to run this PySpark application</strong>.</p><p>Again, take a quick glance through the app/config.py script and then continue reading on:</p><pre>```python<br>### app/config.py<br>import datetime as dt<br>import os<br>import subprocess<br>import sys<br>from pathlib import Path<br><br>import pandas as pd<br>import taipy as tp<br>from taipy import Config<br><br>SCRIPT_DIR = Path(__file__).parent<br>SPARK_APP_PATH = SCRIPT_DIR / &quot;penguin_spark_app.py&quot;<br><br>input_csv_path = str(SCRIPT_DIR / &quot;penguins.csv&quot;)<br><br># -------------------- Data Nodes --------------------<br><br>input_csv_path_cfg = Config.configure_data_node(id=&quot;input_csv_path&quot;, default_data=input_csv_path)<br># Path to save the csv output of the spark app<br>output_csv_path_cfg = Config.configure_data_node(id=&quot;output_csv_path&quot;)<br><br>processed_penguin_df_cfg = Config.configure_parquet_data_node(<br>    id=&quot;processed_penguin_df&quot;, validity_period=dt.timedelta(days=1)<br>)<br><br>species_cfg = Config.configure_data_node(id=&quot;species&quot;)  # &quot;Adelie&quot;, &quot;Chinstrap&quot;, &quot;Gentoo&quot;<br>island_cfg = Config.configure_data_node(id=&quot;island&quot;)  # &quot;Biscoe&quot;, &quot;Dream&quot;, &quot;Torgersen&quot;<br>sex_cfg = Config.configure_data_node(id=&quot;sex&quot;)  # &quot;male&quot;, &quot;female&quot;<br><br>output_cfg = Config.configure_json_data_node(<br>    id=&quot;output&quot;,<br>)<br><br># -------------------- Tasks --------------------<br><br>def spark_process(input_csv_path: str, output_csv_path: str) -&gt; pd.DataFrame:<br>    proc = subprocess.Popen(<br>        [<br>            str(Path(sys.executable).with_name(&quot;spark-submit&quot;)),<br>            str(SPARK_APP_PATH),<br>            &quot;--input-csv-path&quot;,<br>            input_csv_path,<br>            &quot;--output-csv-path&quot;,<br>            output_csv_path,<br>        ],<br>        stdout=subprocess.PIPE,<br>        stderr=subprocess.PIPE,<br>    )<br><br>    try:<br>        outs, errs = proc.communicate(timeout=15)<br>    except subprocess.TimeoutExpired:<br>        proc.kill()<br>        outs, errs = proc.communicate()<br><br>    if proc.returncode != os.EX_OK:<br>        raise Exception(&quot;Spark training failed&quot;)<br><br>    df = pd.read_csv(output_csv_path)<br><br>    return df<br><br>def filter(penguin_df: pd.DataFrame, species: str, island: str, sex: str) -&gt; dict:<br>    df = penguin_df[(penguin_df.species == species) &amp; (penguin_df.island == island) &amp; (penguin_df.sex == sex)]<br>    output = df[[&quot;bill_length_mm&quot;, &quot;bill_depth_mm&quot;, &quot;flipper_length_mm&quot;, &quot;body_mass_g&quot;]].to_dict(orient=&quot;records&quot;)<br>    return output[0] if output else dict()<br><br>spark_process_task_cfg = Config.configure_task(<br>    id=&quot;spark_process&quot;,<br>    function=spark_process,<br>    skippable=True,<br>    input=[input_csv_path_cfg, output_csv_path_cfg],<br>    output=processed_penguin_df_cfg,<br>)<br><br>filter_task_cfg = Config.configure_task(<br>    id=&quot;filter&quot;,<br>    function=filter,<br>    skippable=True,<br>    input=[processed_penguin_df_cfg, species_cfg, island_cfg, sex_cfg],<br>    output=output_cfg,<br>)<br><br>scenario_cfg = Config.configure_scenario(<br>    id=&quot;scenario&quot;, task_configs=[spark_process_task_cfg, filter_task_cfg]<br>)<br><br>```</pre><p>You can also <strong>build the Taipy configuration using </strong><a href="https://docs.taipy.io/en/latest/manuals/studio/config/"><strong>Taipy Studio</strong></a>, a Visual Studio Code extension which provides a graphical editor for building a Taipy .toml configuration file.</p><h3>The PySpark task in Taipy</h3><p>We are particularly interested in the code section which produces this part of the DAG:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*CSjQRTZtEy_gAnSXbUJ6FA.png" /></figure><p>Let’s extract and examine the relevant section of the config.pyscript which creates the “<em>spark_process</em>” Spark task (and its 3 associated data nodes) in Taipy as shown in the image above:</p><pre>### Code snippet: Spark task in Taipy<br><br># -------------------- Data Nodes --------------------<br><br>input_csv_path_cfg = Config.configure_data_node(id=&quot;input_csv_path&quot;, default_data=input_csv_path)<br># Path to save the csv output of the spark app<br>output_csv_path_cfg = Config.configure_data_node(id=&quot;output_csv_path&quot;)<br><br>processed_penguin_df_cfg = Config.configure_parquet_data_node(<br>    id=&quot;processed_penguin_df&quot;, validity_period=dt.timedelta(days=1)<br>)<br><br># -------------------- Tasks --------------------<br><br>def spark_process(input_csv_path: str, output_csv_path: str) -&gt; pd.DataFrame:<br>    proc = subprocess.Popen(<br>        [<br>            str(Path(sys.executable).with_name(&quot;spark-submit&quot;)),<br>            str(SPARK_APP_PATH),<br>            &quot;--input-csv-path&quot;,<br>            input_csv_path,<br>            &quot;--output-csv-path&quot;,<br>            output_csv_path,<br>        ],<br>        stdout=subprocess.PIPE,<br>        stderr=subprocess.PIPE,<br>    )<br><br>    try:<br>        outs, errs = proc.communicate(timeout=15)<br>    except subprocess.TimeoutExpired:<br>        proc.kill()<br>        outs, errs = proc.communicate()<br><br>    if proc.returncode != os.EX_OK:<br>        raise Exception(&quot;Spark training failed&quot;)<br><br>    df = pd.read_csv(output_csv_path)<br><br>    return df<br><br>spark_process_task_cfg = Config.configure_task(<br>    id=&quot;spark_process&quot;,<br>    function=spark_process,<br>    skippable=True,<br>    input=[input_csv_path_cfg, output_csv_path_cfg],<br>    output=processed_penguin_df_cfg,<br>)</pre><p>Since we designed the penguin_spark_app.py Spark application to receive 2 parameters (input_csv_path and output_csv_path), we chose to represent these 2 parameters as Taipy data nodes. Note that <strong>your use case may differ, and you can (and should!) modify the task, function and associated data nodes</strong> according to your needs. For example, you may:</p><ol><li>Have a Spark task which performs some routine ETL and returns nothing;</li><li>Prefer to hard code the input and output paths instead of persisting them as data nodes; or</li><li>Save additional application parameters as data nodes and pass them to the Spark application.</li></ol><p>Then, we run spark-submit as a Python subprocess like so:</p><pre>subprocess.Popen(<br>    [<br>        str(Path(sys.executable).with_name(&quot;spark-submit&quot;)),<br>        str(SPARK_APP_PATH),<br>        &quot;--input-csv-path&quot;,<br>        input_csv_path,<br>        &quot;--output-csv-path&quot;,<br>        output_csv_path,<br>    ],<br>)</pre><p>Recall that the order of the list elements should retain the following format, as if they were executed on the command line:</p><pre>$ spark-submit [spark-arguments] &lt;pyspark-app-path&gt; [application-arguments]</pre><p>Again, depending on our use case, we could specify a different spark-submit script path, Spark arguments (we supplied none in our example) or different application arguments based on our needs.</p><h3>Reading and returning output_csv_path</h3><p>Notice that the <em>spark_process</em> function ended like so:</p><pre>def spark_process(input_csv_path: str, output_csv_path: str) -&gt; pd.DataFrame:<br>    ...<br><br>    df = pd.read_csv(output_csv_path)<br><br>    return df</pre><p>In our case, we want our Taipy task to output the data after it is processed by Spark — so that it can be written to the processed_penguin_df_cfg <a href="https://docs.taipy.io/en/latest/manuals/core/config/data-node-config/#parquet">Parquet data node</a>. One way we can do this is by manually reading from the output target (in this case, output_csv_path) and then returning it as a Pandas DataFrame.</p><p>However, if you don’t need the return data of the Spark application, you can simply have your Taipy task (via the <em>spark_process</em> function) return None.</p><h3>Caching the Spark Task</h3><p>Since we configured spark_process_task_cfg with the <strong><em>skippable</em> property</strong> set to True, when re-executing the scenario, Taipy will <strong>skip the re-execution of the <em>spark_process</em> task</strong> and reuse the persisted task output: the processed_penguin_df_cfg Pandas DataFrame.</p><p>However, we also defined a <em>validity_period</em> of 1 day for the <em>processed_penguin_df_cfg</em> data node, so Taipy will still re-run the task if the DataFrame was last cached more than a day ago.</p><h3>3. Building a GUI (main.py)</h3><p>We’ll complete our application by <strong>building the GUI</strong> which we saw at the beginning of this article:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a7sy2GmZaTYsFH8GVByfSw.png" /></figure><p>If you’re unfamiliar with Taipy’s GUI capabilities, you can find a <a href="https://docs.taipy.io/en/latest/getting_started/getting-started-gui/">quickstart here</a>. In any case, you can just copy and paste the following code for <em>app/main.py</em> since it isn’t our focus:</p><pre>### app/main.py<br>from pathlib import Path<br>from typing import Optional<br><br>import taipy as tp<br>from config import scenario_cfg<br>from taipy.gui import Gui, notify<br><br><br>valid_features: dict[str, list[str]] = {<br>    &quot;species&quot;: [&quot;Adelie&quot;, &quot;Chinstrap&quot;, &quot;Gentoo&quot;],<br>    &quot;island&quot;: [&quot;Torgersen&quot;, &quot;Biscoe&quot;, &quot;Dream&quot;],<br>    &quot;sex&quot;: [&quot;Male&quot;, &quot;Female&quot;],<br>}<br><br>selected_species = valid_features[&quot;species&quot;][0]<br>selected_island = valid_features[&quot;island&quot;][0]<br>selected_sex = valid_features[&quot;sex&quot;][0]<br><br>selected_scenario: Optional[tp.Scenario] = None<br><br>data_dir = Path(__file__).with_name(&quot;data&quot;)<br>data_dir.mkdir(exist_ok=True)<br><br><br>def scenario_on_creation(state, id, payload):<br>    _ = payload[&quot;config&quot;]<br>    date = payload[&quot;date&quot;]<br>    label = payload[&quot;label&quot;]<br>    properties = payload[&quot;properties&quot;]<br><br>    # Create scenario with selected configuration<br>    scenario = tp.create_scenario(scenario_cfg, creation_date=date, name=label)<br>    scenario.properties.update(properties)<br><br>    # Write the selected GUI values to the scenario<br>    scenario.species.write(state.selected_species)<br>    scenario.island.write(state.selected_island)<br>    scenario.sex.write(state.selected_sex.lower())<br>    output_csv_file = data_dir / f&quot;{scenario.id}.csv&quot;<br>    scenario.output_csv_path.write(str(output_csv_file))<br><br>    notify(state, &quot;S&quot;, f&quot;Created {scenario.id}&quot;)<br><br>    return scenario<br><br><br>def scenario_on_submission_change(state, submittable, details):<br>    &quot;&quot;&quot;When the selected_scenario&#39;s submission status changes, reassign selected_scenario to force a GUI refresh.&quot;&quot;&quot;<br><br>    state.selected_scenario = submittable<br><br><br>selected_data_node = None<br><br>main_md = &quot;&quot;&quot;<br>&lt;|layout|columns=1 4|gap=1.5rem|<br><br>&lt;lhs|part|<br># Spark with **Taipy**{: .color-primary}<br><br>## Scenario<br><br>&lt;|{selected_scenario}|scenario_selector|on_creation=scenario_on_creation|&gt;<br><br>----------<br><br>## Scenario info<br><br>&lt;|{selected_scenario}|scenario|on_submission_change=scenario_on_submission_change|&gt;<br><br>|lhs&gt;<br><br>&lt;rhs|part|render={selected_scenario}|<br><br>## Selections<br><br>&lt;selections|layout|columns=1 1 1 2|gap=1.5rem|<br><br>&lt;|{selected_species}|selector|lov={valid_features[&quot;species&quot;]}|dropdown|label=Species|&gt;<br><br>&lt;|{selected_island}|selector|lov={valid_features[&quot;island&quot;]}|dropdown|label=Island|&gt;<br><br>&lt;|{selected_sex}|selector|lov={valid_features[&quot;sex&quot;]}|dropdown|label=Sex|&gt;<br><br>|selections&gt;<br><br>----------<br><br>## Output<br><br>**&lt;|{str(selected_scenario.output.read()) if selected_scenario and selected_scenario.output.is_ready_for_reading else &#39;Submit the scenario using the left panel.&#39;}|text|raw|class_name=color-primary|&gt;**<br><br>## Data node inspector<br><br>&lt;|{selected_data_node}|data_node_selector|display_cycles=False|&gt;<br><br>**Data node value:**<br><br>&lt;|{str(selected_data_node.read()) if selected_data_node and selected_data_node.is_ready_for_reading else None}|&gt;<br><br>&lt;br/&gt;<br><br>----------<br><br>## DAG<br><br>&lt;|Scenario DAG|expandable|<br>&lt;|{selected_scenario}|scenario_dag|&gt;<br>|&gt;<br><br>|rhs&gt;<br><br>|&gt;<br>&quot;&quot;&quot;<br><br><br>def on_change(state, var_name: str, var_value):<br>    if var_name == &quot;selected_species&quot;:<br>        state.selected_scenario.species.write(var_value)<br>    elif var_name == &quot;selected_island&quot;:<br>        state.selected_scenario.island.write(var_value)<br>    elif var_name == &quot;selected_sex&quot;:<br>        state.selected_scenario.sex.write(var_value.lower())<br><br><br>if __name__ == &quot;__main__&quot;:<br>    tp.Core().run()<br><br>    gui = Gui(main_md)<br>    gui.run(title=&quot;Spark with Taipy&quot;)</pre><p>Then, from the project folder, you can run the main script like so:</p><pre>$ taipy run app/main.py</pre><h3>Conclusion</h3><p>Now that you’ve seen an example of how to use PySpark with Taipy, go on and try using these two tools to <strong>enhance your own data applications</strong>!</p><p>If you’ve struggled with other workflow orchestration tools slowing down your work and getting in your way, don’t let it deter you from trying Taipy. Taipy is easy to use and strives to not limit itself in which 3rd party packages you can use it with — <strong>its robust and flexible framework makes it easy to adapt it to any data application</strong>.</p><p>You can find all the code and data in this <a href="https://github.com/Avaiga/demo-pytorch-penguin-app">repository</a>.</p><p>Subscribe to DDIntel <a href="https://www.ddintel.com/">Here</a>.</p><p>Have a unique story to share? Submit to DDIntel <a href="https://datadriveninvestor.com/ddintelsubmission">here</a>.</p><p>Join our creator ecosystem <a href="https://join.datadriveninvestor.com/">here</a>.</p><p><a href="https://ddintel.datadriveninvestor.com/"><em>DDIntel</em> </a>captures the more notable pieces from our <a href="https://www.datadriveninvestor.com/"><em>main site</em></a> and our popular <a href="https://medium.datadriveninvestor.com/"><em>DDI Medium publication</em></a>. Check us out for more insightful work from our community.</p><p>DDI Official Telegram Channel: <a href="https://t.me/+tafUp6ecEys4YjQ1">https://t.me/+tafUp6ecEys4YjQ1</a></p><p>Follow us on <a href="https://www.linkedin.com/company/data-driven-investor"><em>LinkedIn</em></a>, <a href="https://twitter.com/@DDInvestorHQ"><em>Twitter</em></a>, <a href="https://www.youtube.com/c/datadriveninvestor"><em>YouTube</em></a>, and <a href="https://www.facebook.com/datadriveninvestor"><em>Facebook</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a594ce47070c" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/how-to-master-big-data-pipelines-with-pyspark-and-taipy-a594ce47070c">How to master Big Data pipelines with PySpark and Taipy</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big data models vs. Computer memory]]></title>
            <link>https://itnext.io/big-data-models-vs-computer-memory-b345814ece9f?source=rss-ea1c64d90586------2</link>
            <guid isPermaLink="false">https://medium.com/p/b345814ece9f</guid>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Marine Gosselin]]></dc:creator>
            <pubDate>Fri, 17 Nov 2023 10:45:42 GMT</pubDate>
            <atom:updated>2023-11-21T13:55:11.910Z</atom:updated>
            <content:encoded><![CDATA[<p>A guide to building models that are bigger than your computer memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*tphLsiOVugqfi7aeGvIw4g.gif" /></figure><p>Data pipelines are the backbone of any data-intensive project. <strong>As datasets grow</strong> beyond memory size (“out-of-core”), <strong>handling them efficiently becomes challenging</strong>. Dask enables effortless management of large datasets (out-of-core), offering great compatibility with Numpy and Pandas.</p><p>This article focuses on the <strong>seamless integration of Dask (for handling out-of-core data) with Taipy</strong>, a Python library used for <strong>pipeline orchestration and scenario management</strong>.</p><h3>1. Sample Application</h3><p>Integrating Dask and Taipy is demonstrated best with an example. In this article, we’ll consider a Taipy data workflow with 4 tasks:</p><ul><li><strong>Data Preprocessing and Customer Scoring</strong><br>Read and process a large dataset using Dask.</li><li><strong>Feature Engineering and Segmentation</strong><br>Score customers based on purchase behavior.</li><li><strong>Segment Analysis</strong><br>Segment customers into different categories based on these scores and other factors.</li><li><strong>Summary Statistics for High-Value Customers</strong><br>Analyze each customer segment to derive insights</li></ul><p>We will explore the code of these 4 tasks in finer detail. Note that this code is your Python code and is not using Taipy. In a later section, we will show how you can use Taipy to model your existing data applications, and reap the benefits of its workflow orchestration with little effort.</p><p>The application will comprise of the following 5 files:</p><pre>algos/<br>├─ algo.py  #  Our existing code with 4 tasks<br>data/<br>├─ SMALL_amazon_customers_data.csv  #  A sample dataset<br>app.ipynb  # Jupyter Notebook for running our sample data application<br>config.py  # Taipy configuration which models our data workflow<br>config.toml  # (Optional) Taipy configuration in TOML made using Taipy Studio</pre><h3>2. Introducing Taipy — A Comprehensive Solution</h3><p><a href="https://docs.taipy.io/">Taipy</a> is <strong>more than just another orchestration tool</strong>. Especially designed for ML engineers, data scientists, and Python developers, Taipy brings several essential and simple features.</p><blockquote><strong>It would be awesome if you could add a </strong><a href="https://github.com/Avaiga/taipy"><strong>star</strong>⭐<strong>to our repository</strong></a><strong>! We’re getting close to 1000 </strong>⭐<strong>, thanks to you ❤</strong></blockquote><p>Here are <strong>some key elements</strong> that make Taipy a compelling choice:</p><ol><li><strong>Pipeline execution registry</strong> — This feature enables developers and end-users to:</li></ol><ul><li>Register each pipeline execution as a “<em>Scenario</em>” (a graph of tasks and data nodes);</li><li>Precisely trace the lineage of each pipeline execution; and</li><li>Compare scenarios with ease, monitor KPIs and provide invaluable insight for troubleshooting and fine-tuning parameters.</li></ul><p><strong>2. Pipeline versioning</strong><br>Taipy’s robust scenario management enables you to adapt your pipelines to evolving project demands effortlessly.</p><p><strong>3. Smart task orchestration</strong><br>Taipy allows the developer to model the network of tasks and data sources easily. This feature provides a built-in control over the execution of your tasks with:</p><ul><li>Parallel execution of your tasks; and</li><li>Task “skipping”, i.e., choosing which tasks to execute and<br>which to bypass.</li></ul><p><strong>4. Modular approach to task orchestration</strong><br>Modularity isn’t just a buzzword with Taipy; it’s a core principle. Setting up tasks and data sources that can be used interchangeably, resulting in a cleaner, more maintainable codebase.</p><h3>3. Introducing Dask</h3><p>Dask is a popular Python package for distributed computing. The Dask API implements the familiar Pandas, Numpy and Scikit-learn APIs — which makes learning and using Dask much more pleasant for the many data scientists whom are already familiar with these APIs.</p><p>If you’re new to Dask, check out the excellent <a href="https://docs.dask.org/en/stable/10-minutes-to-dask.html">10-minute Introduction to Dask</a> by the Dask team.</p><h3>4. Application: Customer Analysis (<em>algos/algo.py</em>)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KzguUmBXX8aOj3jry7yQDQ.png" /><figcaption>A graph of our 4 tasks (in orange) which we will model in the next section.</figcaption></figure><p>Our existing code (without Taipy) comprises of 4 functions, which you can also see in the graph above:</p><ul><li>Task 1: <em>preprocess_and_score</em></li><li>Task 2:<em>featurization_and_segmentation</em></li><li>Task 3: <em>segment_analysis</em></li><li>Task 4: <em>high_value_cust_summary_statistics</em></li></ul><p>You can skim through the following <em>algos/algos.py</em>script which defines the 4 functions and then continue reading on for a brief description of what each function does:</p><pre>### algos/algo.py<br>import time<br><br>import dask.dataframe as dd<br>import pandas as pd<br><br><br>def preprocess_and_score(path_to_original_data: str):<br>    print(&quot;__________________________________________________________&quot;)<br>    print(&quot;1. TASK 1: DATA PREPROCESSING AND CUSTOMER SCORING ...&quot;)<br>    start_time = time.perf_counter()  # Start the timer<br><br>    # Step 1: Read data using Dask<br>    df = dd.read_csv(path_to_original_data)<br><br>    # Step 2: Simplify the customer scoring formula<br>    df[&quot;CUSTOMER_SCORE&quot;] = (<br>        0.5 * df[&quot;TotalPurchaseAmount&quot;] / 1000 + 0.3 * df[&quot;NumberOfPurchases&quot;] / 10 + 0.2 * df[&quot;AverageReviewScore&quot;]<br>    )<br><br>    # Save all customers to a new CSV file<br>    scored_df = df[[&quot;CUSTOMER_SCORE&quot;, &quot;TotalPurchaseAmount&quot;, &quot;NumberOfPurchases&quot;, &quot;TotalPurchaseTime&quot;]]<br><br>    pd_df = scored_df.compute()<br><br>    end_time = time.perf_counter()  # Stop the timer<br>    execution_time = (end_time - start_time) * 1000  # Calculate the time in milliseconds<br>    print(f&quot;Time of Execution: {execution_time:.4f} ms&quot;)<br><br>    return pd_df<br><br><br>def featurization_and_segmentation(scored_df, payment_threshold, score_threshold):<br>    print(&quot;__________________________________________________________&quot;)<br>    print(&quot;2. TASK 2: FEATURE ENGINEERING AND SEGMENTATION ...&quot;)<br><br>    # payment_threshold, score_threshold = float(payment_threshold), float(score_threshold)<br>    start_time = time.perf_counter()  # Start the timer<br><br>    df = scored_df<br><br>    # Feature: Indicator if customer&#39;s total purchase is above the payment threshold<br>    df[&quot;HighSpender&quot;] = (df[&quot;TotalPurchaseAmount&quot;] &gt; payment_threshold).astype(int)<br><br>    # Feature: Average time between purchases<br>    df[&quot;AverageTimeBetweenPurchases&quot;] = df[&quot;TotalPurchaseTime&quot;] / df[&quot;NumberOfPurchases&quot;]<br><br>    # Additional computationally intensive features<br>    df[&quot;Interaction1&quot;] = df[&quot;TotalPurchaseAmount&quot;] * df[&quot;NumberOfPurchases&quot;]<br>    df[&quot;Interaction2&quot;] = df[&quot;TotalPurchaseTime&quot;] * df[&quot;CUSTOMER_SCORE&quot;]<br>    df[&quot;PolynomialFeature&quot;] = df[&quot;TotalPurchaseAmount&quot;] ** 2<br><br>    # Segment customers based on the score_threshold<br>    df[&quot;ValueSegment&quot;] = [&quot;High Value&quot; if score &gt; score_threshold else &quot;Low Value&quot; for score in df[&quot;CUSTOMER_SCORE&quot;]]<br><br>    end_time = time.perf_counter()  # Stop the timer<br>    execution_time = (end_time - start_time) * 1000  # Calculate the time in milliseconds<br>    print(f&quot;Time of Execution: {execution_time:.4f} ms&quot;)<br><br>    return df<br><br><br>def segment_analysis(df: pd.DataFrame, metric):<br>    print(&quot;__________________________________________________________&quot;)<br>    print(&quot;3. TASK 3: SEGMENT ANALYSIS ...&quot;)<br>    start_time = time.perf_counter()  # Start the timer<br><br>    # Detailed analysis for each segment: mean/median of various metrics<br>    segment_analysis = (<br>        df.groupby(&quot;ValueSegment&quot;)<br>        .agg(<br>            {<br>                &quot;CUSTOMER_SCORE&quot;: metric,<br>                &quot;TotalPurchaseAmount&quot;: metric,<br>                &quot;NumberOfPurchases&quot;: metric,<br>                &quot;TotalPurchaseTime&quot;: metric,<br>                &quot;HighSpender&quot;: &quot;sum&quot;,  # Total number of high spenders in each segment<br>                &quot;AverageTimeBetweenPurchases&quot;: metric,<br>            }<br>        )<br>        .reset_index()<br>    )<br><br>    end_time = time.perf_counter()  # Stop the timer<br>    execution_time = (end_time - start_time) * 1000  # Calculate the time in milliseconds<br>    print(f&quot;Time of Execution: {execution_time:.4f} ms&quot;)<br><br>    return segment_analysis<br><br><br>def high_value_cust_summary_statistics(df: pd.DataFrame, segment_analysis: pd.DataFrame, summary_statistic_type: str):<br>    print(&quot;__________________________________________________________&quot;)<br>    print(&quot;4. TASK 4: ADDITIONAL ANALYSIS BASED ON SEGMENT ANALYSIS ...&quot;)<br>    start_time = time.perf_counter()  # Start the timer<br><br>    # Filter out the High Value customers<br>    high_value_customers = df[df[&quot;ValueSegment&quot;] == &quot;High Value&quot;]<br><br>    # Use summary_statistic_type to calculate different types of summary statistics<br>    if summary_statistic_type == &quot;mean&quot;:<br>        average_purchase_high_value = high_value_customers[&quot;TotalPurchaseAmount&quot;].mean()<br>    elif summary_statistic_type == &quot;median&quot;:<br>        average_purchase_high_value = high_value_customers[&quot;TotalPurchaseAmount&quot;].median()<br>    elif summary_statistic_type == &quot;max&quot;:<br>        average_purchase_high_value = high_value_customers[&quot;TotalPurchaseAmount&quot;].max()<br>    elif summary_statistic_type == &quot;min&quot;:<br>        average_purchase_high_value = high_value_customers[&quot;TotalPurchaseAmount&quot;].min()<br><br>    median_score_high_value = high_value_customers[&quot;CUSTOMER_SCORE&quot;].median()<br><br>    # Fetch the summary statistic for &#39;TotalPurchaseAmount&#39; for High Value customers from segment_analysis<br>    segment_statistic_high_value = segment_analysis.loc[<br>        segment_analysis[&quot;ValueSegment&quot;] == &quot;High Value&quot;, &quot;TotalPurchaseAmount&quot;<br>    ].values[0]<br><br>    # Create a DataFrame to hold the results<br>    result_df = pd.DataFrame(<br>        {<br>            &quot;SummaryStatisticType&quot;: [summary_statistic_type],<br>            &quot;AveragePurchaseHighValue&quot;: [average_purchase_high_value],<br>            &quot;MedianScoreHighValue&quot;: [median_score_high_value],<br>            &quot;SegmentAnalysisHighValue&quot;: [segment_statistic_high_value],<br>        }<br>    )<br><br>    end_time = time.perf_counter()  # Stop the timer<br>    execution_time = (end_time - start_time) * 1000  # Calculate the time in milliseconds<br>    print(f&quot;Time of Execution: {execution_time:.4f} ms&quot;)<br><br>    return result_df</pre><h3>Task 1 — Data Preprocessing and Customer Scoring</h3><p><strong>Python function: </strong><em>preprocess_and_score</em><br>This is the first step in your pipeline and perhaps the most crucial. It reads a large dataset using <strong>Dask</strong>, designed for larger-than-memory computation. It then calculates a “<em>Customer Score</em>” in a DataFrame named <em>scored_df</em>, based on various metrics like “<em>TotalPurchaseAmount</em>”, “<em>NumberOfPurchases</em>”, and “<em>AverageReviewScore</em>”.</p><p>After reading and processing the dataset with Dask, this task will output a Pandas DataFrame for further use in the remaining 3 tasks.</p><h3>Task 2 — Feature Engineering and Segmentation</h3><p><strong>Python function: </strong><em>featurization_and_segmentation</em><br>This task takes the scored DataFrame and adds new features, such as an indicator for high spending. It also segments the customers based on their scores.</p><h3>Task 3 — Segment Analysis</h3><p><strong>Python function: </strong><em>segment_analysis</em><br>This task takes the segmented DataFrame and performs a group-wise analysis based on the customer segments to calculate various metrics.</p><h3>Task 4 — Summary Statistics for High-Value Customers</h3><p><strong>Python function: </strong><em>high_value_cust_summary_statistics</em><br>This task performs an in-depth analysis of the high-value customer segment and returns summary statistics.</p><h3>5. Modelling the Workflow in Taipy (config.py)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SSVhGmaWoRoo6xn55LE39w.png" /><figcaption>Taipy DAG — Taipy “Tasks” in orange and “Data Nodes” in blue.</figcaption></figure><p>In this section, we will create the Taipy configuration which models the variables/parameters (represented as <a href="https://docs.taipy.io/en/latest/manuals/core/concepts/data-node/">“Data Nodes”</a>) and functions (represented as <a href="https://docs.taipy.io/en/latest/manuals/core/concepts/task/">“Tasks”</a>) in Taipy.</p><p>Notice that this configuration in the following <em>config.py</em>script is akin to defining variables and functions — except that we are instead defining “blueprint variables” (Data Nodes) and “blueprint functions” (Tasks). We are informing Taipy on how to call the functions we defined earlier, default values of Data Nodes (which we may overwrite at runtime), and if Tasks may be skipped:</p><pre>### config.py<br>from taipy import Config<br><br>from algos.algo import (<br>    preprocess_and_score,<br>    featurization_and_segmentation,<br>    segment_analysis,<br>    high_value_cust_summary_statistics,<br>)<br><br># -------------------- Data Nodes --------------------<br><br>path_to_data_cfg = Config.configure_data_node(id=&quot;path_to_data&quot;, default_data=&quot;data/customers_data.csv&quot;)<br><br>scored_df_cfg = Config.configure_data_node(id=&quot;scored_df&quot;)<br><br>payment_threshold_cfg = Config.configure_data_node(id=&quot;payment_threshold&quot;, default_data=1000)<br><br>score_threshold_cfg = Config.configure_data_node(id=&quot;score_threshold&quot;, default_data=1.5)<br><br>segmented_customer_df_cfg = Config.configure_data_node(id=&quot;segmented_customer_df&quot;)<br><br>metric_cfg = Config.configure_data_node(id=&quot;metric&quot;, default_data=&quot;mean&quot;)<br><br>segment_result_cfg = Config.configure_data_node(id=&quot;segment_result&quot;)<br><br>summary_statistic_type_cfg = Config.configure_data_node(id=&quot;summary_statistic_type&quot;, default_data=&quot;median&quot;)<br><br>high_value_summary_df_cfg = Config.configure_data_node(id=&quot;high_value_summary_df&quot;)<br><br># -------------------- Tasks --------------------<br><br>preprocess_and_score_task_cfg = Config.configure_task(<br>    id=&quot;preprocess_and_score&quot;,<br>    function=preprocess_and_score,<br>    skippable=True,<br>    input=[path_to_data_cfg],<br>    output=[scored_df_cfg],<br>)<br><br>featurization_and_segmentation_task_cfg = Config.configure_task(<br>    id=&quot;featurization_and_segmentation&quot;,<br>    function=featurization_and_segmentation,<br>    skippable=True,<br>    input=[scored_df_cfg, payment_threshold_cfg, score_threshold_cfg],<br>    output=[segmented_customer_df_cfg],<br>)<br><br>segment_analysis_task_cfg = Config.configure_task(<br>    id=&quot;segment_analysis&quot;,<br>    function=segment_analysis,<br>    skippable=True,<br>    input=[segmented_customer_df_cfg, metric_cfg],<br>    output=[segment_result_cfg],<br>)<br><br>high_value_cust_summary_statistics_task_cfg = Config.configure_task(<br>    id=&quot;high_value_cust_summary_statistics&quot;,<br>    function=high_value_cust_summary_statistics,<br>    skippable=True,<br>    input=[segment_result_cfg, segmented_customer_df_cfg, summary_statistic_type_cfg],<br>    output=[high_value_summary_df_cfg],<br>)<br><br>scenario_cfg = Config.configure_scenario(<br>    id=&quot;scenario_1&quot;,<br>    task_configs=[<br>        preprocess_and_score_task_cfg,<br>        featurization_and_segmentation_task_cfg,<br>        segment_analysis_task_cfg,<br>        high_value_cust_summary_statistics_task_cfg,<br>    ],<br>)</pre><p>You can read more about configuring Scenarios, Tasks and Data Nodes in the <a href="https://docs.taipy.io/en/latest/manuals/core/config/">documentation here</a>.</p><h3>Taipy Studio</h3><p><a href="https://docs.taipy.io/en/latest/manuals/studio/config/"><em>Taipy Studio</em></a><em> </em><strong>is a VS Code extension</strong> from Taipy that allows you to <strong>build and visualize your pipelines with simple drag-and-drop interactions</strong>. Taipy Studio provides a graphical editor where you can create your Taipy configurations <strong>stored in TOML files</strong> that your Taipy application can load to run. The editor represents Scenarios as graphs, where nodes are Data Nodes and Tasks.</p><blockquote>As an <strong>alternative </strong>for the<strong> </strong>config.py script in this section, you may instead <strong>use Taipy Studio to generate a </strong>config.toml<strong> configuration file</strong>. The penultimate section in this article will provide a guide on how to create the config.toml configuration file using Taipy Studio.</blockquote><h3>6. Scenario Creation and Execution</h3><p>Executing a Taipy scenario involves:</p><ul><li>Loading the config;</li><li>Running the Taipy Core service; and</li><li>Creating and submitting the scenario for execution.</li></ul><p>Here’s the basic code template:</p><pre>import taipy as tp<br>from config import scenario_cfg  # Import the Scenario configuration<br>tp.Core().run()  # Start the Core service<br>scenario_1 = tp.create_scenario(scenario_cfg)  # Create a Scenario instance<br>scenario_1.submit()  # Submit the Scenario for execution<br><br># Total runtime: 74.49s</pre><h3>Skip unnecessary task executions</h3><p>One of Taipy’s most practical features is its ability to skip a task execution if its output is already computed. Let’s explore this with some scenarios:</p><h4>Changing Payment Threshold</h4><pre># Changing Payment Threshold to 1600<br>scenario_1.payment_threshold.write(1600)<br>scenario_1.submit()<br><br># Total runtime: 31.499s</pre><p><strong>What Happens:</strong> Taipy is intelligent enough to skip Task 1 because the payment threshold only affects Task 2. In this case, we are seeing more than 50% reduction in execution time by running your pipeline with Taipy.</p><h4>Changing Metric for Segment Analysis</h4><pre># Changing metric to median<br>scenario_1.metric.write(&quot;median&quot;)<br>scenario_1.submit()<br><br># Total runtime: 23.839s</pre><p><strong>What Happens:</strong> In this case, only Task 3 and Task 4 are affected. Taipy smartly skips Task 1 and Task 2.</p><h4>Changing Summary Statistic Type</h4><pre># Changing summary_statistic_type to max<br>scenario_1.summary_statistic_type.write(&quot;max&quot;)<br>scenario_1.submit()<br><br># Total runtime: 5.084s</pre><p><strong>What Happens:</strong> Here, only Task 4 is affected, and Taipy executes only this task, skipping the rest.</p><p>Taipy’s smart task skipping is not just a time-saver; it’s a resource optimizer that becomes incredibly useful when dealing with large datasets.</p><h3>7. Taipy Studio</h3><p>If you have VS Code, you may use Taipy Studio to build the Taipy <em>config.toml</em> configuration file in place of defining the <em>config.py</em>script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ucSY6mOlVgBE7_PzquFEA.png" /></figure><p>First, install the <a href="https://marketplace.visualstudio.com/items?itemName=Taipy.taipy-studio"><strong>Taipy Studio</strong></a> extension using the Extension Marketplace.</p><h3>Creating the Configuration</h3><ol><li><strong>Create a Config File:</strong> In VS Code, navigate to Taipy Studio, and initiate a new TOML configuration file by clicking the + button on the parameters window.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*M9QoD4bqBRxWEoZvg2JFtw.png" /></figure><p>2. Then right-click on it and select <strong>Taipy: Show View</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*I-_AShkIUrWqQqdiD-qcDw.png" /></figure><p>3. <strong>Adding entities</strong> to your Taipy Configurations: On the right-hand side of Taipy Studio, you should see a list of 3 icons that can be used to set up your pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*CuFnaOjBckUi6MaJuuAJfQ.png" /></figure><ul><li>The first item is for adding a Data Node. You can link any Python object to Taipy’s Data Nodes.</li><li>The second item is for adding a Task. A Task can be linked to a predefined Python function.</li><li>The third item is for adding a Scenario. Taipy allows you to have more than one Scenario in a configuration.</li></ul><h3>Data Nodes</h3><ol><li><strong>Input Data Node</strong>: Create a Data Node named “<em>path_to_data</em>”, then navigate to the Details tab, add a new property “<em>default_data</em>”, and paste “<em>data/customers_data.csv</em>” as the path to your dataset.</li><li><strong>Intermediate Data Nodes</strong>: We’ll need to add four more Data Nodes: “<em>scored_df</em>”, “<em>segmented_customer_df</em>”, “<em>segment_result</em>”, “<em>high_value_summary_df</em>”. With Taipy’s intelligent design, you don’t need to configure anything for these intermediate data nodes; the system handles them smartly.</li><li><strong>Intermediate Data Nodes with Defaults</strong>: We finally define four more intermediate Data Nodes with the “<em>default_data</em>” property set to the following:</li></ol><ul><li>payment_threshold: “1000:int”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*d3QG4vKK2BRWH3hr1hIE4w.png" /></figure><ul><li>score_threshold: “1.5:float”</li><li>metric: “mean”</li><li>summary_statistic_type: “median”</li></ul><h3>Tasks</h3><p>Clicking on the Add Task button, you can configure a new Task. Add four Tasks, then <strong>link each Task to the appropriate function</strong> under the Details tab. Taipy Studio will scan through your project folder and provide a categorized list of functions to choose from, sorted by the Python file.</p><p><strong>Task 1</strong> (<em>preprocess_and_score</em>): In Taipy studio, you’d click the Task icon to add a new Task. You’d specify the input as “<em>path_to_data</em>” and the output as “<em>scored_df</em>”. Then, under the Details tab, you’d link this Task to the <em>algos.algo.preprocess_and_score</em> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*HU-K8nXhs2Khh4sVwRIRqQ.png" /></figure><p><strong>Task 2</strong> (<em>featurization_and_segmentation</em>): Similar to Task 1, you’d specify the inputs (”<em>scored_df</em>”, ”<em>payment_threshold</em>”, ”<em>score_threshold</em>”) and the output (”<em>segmented_customer_df</em>”). Link this Task to the <em>algos.algo.featurization_and_segmentation</em> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*IHiVQBvltKFkAbsqV1ZRSA.png" /></figure><p><strong>Task 3</strong> (<em>segment_analysis</em>): Inputs would be “<em>segmented_customer_df</em>” and “<em>metric</em>”, and the output would be “<em>segment_result</em>”. Link to the <em>algos.algo.segment_analysis</em> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*GifAWoWeUCHdarw2w5r8Wg.png" /></figure><p><strong>Task 4</strong> (<em>high_value_cust_summary_statistics</em>): Inputs include “<em>segment_result</em>”, “<em>segmented_customer_df</em>”, and “<em>summary_statistic_type</em>”. The output is “<em>high_value_summary_df</em>”. Link to the <em>algos.algo.high_value_cust_summary_statistics</em> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*tQ_EnYKgvC2ruHHVXycXjA.png" /></figure><h3>Conclusion</h3><p>Taipy offers an <strong>intelligent way to build and manage data pipelines</strong>. The skippable feature in particular, makes it a powerful tool for optimizing computational resources and time, particularly beneficial in scenarios involving large datasets. While <strong>Dask provides the raw power for data manipulation</strong>, <strong>Taipy adds a layer of intelligence</strong>, making your pipeline not just robust but also smart.</p><p><strong><em>Additional Resources</em></strong><br>For the complete code and TOML configuration, you can visit this <a href="https://github.com/Avaiga/demo_dask_customer_analysis/tree/develop">GitHub repository</a>. To dive deeper into Taipy, here’s the <a href="https://docs.taipy.io/en/latest/">official documentation</a>.</p><p>Once you understand Taipy Scenario management, you become much more efficient building data driven application for your end users. <strong>Just focus on your algorithms and Taipy handles the rest!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b345814ece9f" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/big-data-models-vs-computer-memory-b345814ece9f">Big data models vs. Computer memory</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>