Icon

Data Manipulation with Expressions and AI assistant

<p>This workflow aims to demonstrate the use of the Expressions node for data manipulation, including string and integer operations, and to highlight the power of combining AI techniques.</p><p></p><p>You can download and run the workflow directly in your KNIME Analytics Platform. We recommend using the latest KNIME AP version for optimal performance.</p><p></p><p>We are using a fake dataset to show e-commerce performance metrics.</p><p></p><p>Workflow Details:</p><p>Below is how we have used the Expression node within the workflow.</p><ol><li><p><strong>Age Bucket Creation</strong></p><ul><li><p>First, we create an age bucket using an <strong>IF condition</strong>, following the example provided by the node IF expression.</p></li></ul></li><li><p><strong>Expression Node and K-AI Assistant</strong></p><ul><li><p>We use the Expressions node with K-AI (KNIME Assistant) to generate regex patterns for extracting data. Remember to install the AI assistant extension to use this feature. We provide the assistant with two different prompts to achieve the desired results:</p><p></p></li><li><p><strong>Prompt Product ID:</strong></p><p><em>"Generate a regular expression to extract the Product ID from the URL column.</em></p><p><strong>Example:</strong></p><ul><li><p>URL: https://www.fakeecommerce.com/electronics/fire/9b39b2b4-b6a6-418e-a994-8b1c0aad8a54?source=Google</p></li><li><p>Product ID pattern: b39b2b4-b6a6-418e-a994-8b1c0aad8a54"</p></li></ul></li><li><p><strong>Prompt Product Category:</strong></p><p><em>"Generate a regular expression to extract the Product category from the URL column.</em></p><p>The product category is always the first element of the URL pathname."</p></li></ul></li><li><p><strong>Data Transformation</strong></p><ul><li><p>Perform a join operation and apply title case formatting to the Product Category and Age Bucket columns.</p></li></ul></li><li><p><strong>Revenue Calculations</strong></p><ul><li><p>Perform mathematical operations to calculate the percentage of revenues.</p></li></ul></li></ol><p>Finally, with the Table View node, it is possible to visualize the final data.</p>

URL: Extension: KNIME AI Assistant https://hub.knime.com/knime/extensions/org.knime.features.ai.assistant/latest/

Data Manipulation with Expressions and K-AI

  • This workflow aims to demonstrate the use of the Expressions node to manipulate data, both strings and integers and showcase the power of combining it with K-AI, the KNIME assistant.

  • To learn more about the workflow, click the left bar and check the description section.

Fake E-commerceproduct purchase stats
CSV Reader
1. Create an Age Bucket columnusing IF conditions
Expression
2. Extract product ID from the URL via K-AI assistant
Expression
3. Extract product category fromthe URL via K-AI Assistant
Expression
4. Product category in Title case + join with Age Bucket
Expression
Group by product category and agecount the products sold and sum the revenues
GroupBy
Column Renamer
5. Calculate the percentageof revenue
Expression
Visualize the table
Table View

Nodes

Extensions

Links