Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Error’d: Pickup Sticklers

      September 27, 2025

      From Prompt To Partner: Designing Your Custom AI Assistant

      September 27, 2025

      Microsoft unveils reimagined Marketplace for cloud solutions, AI apps, and more

      September 27, 2025

      Design Dialects: Breaking the Rules, Not the System

      September 27, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Cailabs secures €57M to accelerate growth and industrial scale-up

      September 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025
      Recent

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025

      Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

      September 28, 2025

      The first browser with JavaScript landed 30 years ago

      September 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured
      Recent
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Using AI to Compare Retail Product Performance

    Using AI to Compare Retail Product Performance

    June 30, 2025

    AI this, AI that. It seems like everyone is trying to shoehorn AI into everything even if it doesn’t make sense. Many of the use cases I come across online are either not a fit for AI or could be easily done without it. However, below I explore a use case that is not only a good fit, but also very much accelerated by the use of AI.

     

    The Use Case

    In the retail world, sometimes you have products that don’t seem to sell well even though they might be very similar to another product that does. Being able to group these products and analyze them as a cohort is the first useful step in understanding why.

     

    The Data and Toolset

    For this particular exercise I will be using a retail sales dataset from Zara that I got from Kaggle. It contains information about sales as well as the description of the items.

    The tools I will be using are:

      • Ollama (to run LLMs locally)
      • Gemma3 LLM
      • Python
          • Pandas
          • Langchain
      • Power BI
     

    High-level actions

    I spend a lot of my time design solutions and one thing I’ve learned is that creating a high-level workflow is crucial in the early stages of solutioning. It allows for quick critique, communication, and change, if needed. This particular solution is not very complex, nevertheless, below are the high-level actions we will be performing.

    1. Load the csv data onto memory using Pandas
    2. Create a Vector Store to store our embeddings.
      1. Embed the description of the products
    3. Modify the Pandas dataframe to accommodate the results we want to get.
    4. Create a template that will be sent to the LLM for analysis
    5. Process each product on its own
      1. Get a list of comparable products based on the description. (This is where we leverage the LLM)
      2. Capture comparable products
      3. Rank the comparable products based on sales volume
    6. Output the data onto a new CSV
    7. Load the CSV onto PowerBI for visualization
      1. Add thresholding and filters.

    The Code

    All of the code for this exercise can be found here

     

    The Template

    Creating a template to send to the LLM is crucial. You can play around with it to see what works best and modify it to fit your scenario. What I used was this:

     
    <span class="line"><span>template</span> <span>=</span> <span>"""</span><span><br>    You are an expert business analyst that specializes in retail sales analysis.<br>    The data you need is provided below. It is in dictionary format including:<br>    </span><span>"</span><span>Product</span> <span>Position</span><span>"</span><span>: Where the product is positioned within the store,<br>    </span><span>"</span><span>Sales</span> <span>Volume</span><span>"</span><span>: How many units of a given product were sold,<br>    </span><span>"</span><span>Product</span> <span>Category</span><span>"</span><span>: The category for the product,<br>    </span><span>"</span><span>Promotion</span><span>"</span><span>: Whether or not the product was sold during a promotion.<br>    There is additional information such as the name of the product, price, description, and more.<br>    Here is all the data you need to answer questions: {data}<br>    Here is the question to answer: {question}<br>    When referencing products, add a list of the Product IDs at the end of your response in the following format: 'product_ids = [<id1>, <id2>, ... ]'.<br></span><span>"""</span></span>

    When we iterate, we will use the following as the question:

     
    <span class="line"><span>question</span> <span>=</span> <span>f</span><span>"</span><span>Look for 5 products that loosely match this description: {product['description']}?</span><span>"</span></span>

     

    The output

    Once python does its thing and iterates over all the products we get something like this:

    Product ID Product Name Product Description Sales Volume Comparable Product 1 Comparable Product 2 … Group Ranking
    185102 BASIC PUFFER JACKET Puffer jacket made of tear-resistant… 2823 133100 128179 … 1
    187234 STRETCH POCKET OVERSHIRT Overshirt made of stretchy fabric…. 2575 134104 182306 … 0.75
    … … … … … … … …

     

    Power BI

    We then load the data onto Power BI to visualize it better. This will allow us to not only analyze the data using filtering and conditional formatting, but we can also explore the data even further with Copilot.

    Look at the screenshot below. I’ve initially setup conditional formatting so that all the products that rank low within their group are highlighted.

    I then used Copilot to ask how all of these relate to each other. It was quick to point out that all of them were jackets.

    Pbi Copilot

    This arms us with enough information to go down a narrower search to figure out why the products are not performing. Some other questions we could ask are:

    1. Is this data seasonal and only includes summer sales?
    2. How long have these jackets been on sale?
    3. Are they all sold within a specific region or along all the stores?
    4. etc.

    Conclusion

    Yes, there are many, many use cases that don’t make sense for AI, however there are many that do! I hope that what you just read sparks some creativity in how you can use AI to further analyze data. The one thing to remember is that in order for AI to work as it should, it needs contextual information about the data. That can be accomplished via semantic layers. To know more, got to my post on semantic layers. 

    Do you have a business problem and need to talk to an expert about how to go about it? Are you unsure how AI can help? Reach out and we can talk about it!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLaravel Virtual Wallet
    Next Article Wire Room Math: AI + SME = (Less Compensation Paid) X (Headline Risk + Payment Errors)^2

    Related Posts

    Development

    Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

    September 28, 2025
    Development

    Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

    September 28, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Azure IoT Operations: Empowering the Future of Connectivity and Automation

    Development

    Yandex Releases Alchemist: A Compact Supervised Fine-Tuning Dataset for Enhancing Text-to-Image T2I Model Quality

    Machine Learning

    Mistral AI Introduces Codestral Embed: A High-Performance Code Embedding Model for Scalable Retrieval and Semantic Understanding

    Machine Learning

    Explore the best of GitHub Universe: 9 spaces built to spark creativity, connection, and joy

    News & Updates

    Highlights

    Development

    The Intersection of Agile and Accessibility – Writing Inclusive User Stories and Acceptance Criteria

    July 25, 2025

    Welcome back to our session on Agile and Accessibility, where we bring together two powerful…

    Intelligent Agents with n8n: AI-Powered Automation

    July 4, 2025

    AI in Healthcare: Transforming Diagnosis, Treatment & Patient Care Excellence🧠

    May 20, 2025

    Smashing Security podcast #425: Call of Duty: From pew-pew to pwned

    July 9, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.