How to Build ML Apps in Seeq with ChatGPT

Combine the power of Seeq and ChatGPT to bring new analytics ideas to life.

April 26, 2023

In today’s world, data-driven decision-making has become the backbone of almost every industry, and to gain greater insights into manufacturing and industrial processes, companies are continuing to invest heavily in advanced analytics solutions.

With all the options on the market, it can be difficult to find a software solution that handles all possible analytic and visualization needs. Understanding this, Seeq launched Data Lab in 2020, an embedded Python experience for creating custom Add-ons or scripts. This enables users to make use of Python libraries for sophisticated data analytics and visualizations that may not be readily available in Seeq Workbench or Organizer.

The ability to create and build custom analytics tools in Seeq drastically opens the “art of the possible” to almost any idea. Seeq has already created widely available Add-ons, found in our Add-on Gallery, and many of our customers have also developed custom Add-ons to increase their users’ capabilities. However, many organizations do not have the necessary programming resources to take full advantage of what Data Lab offers. This is where ChatGPT comes in, an AI technology that bridges the gap between users’ ideas and the code required to make them reality.

ChatGPT’s Potential

ChatGPT is an advanced, large-language model that can understand complex context and provide accurate code snippets, helping users create their own Add-ons without prior Python programming experience. It can be thought of as an extremely intelligent colleague with whom users can interact in complete, detailed dialogue. As such, it’s capable of helping build custom tools for machine learning anomaly detection, clustering, correlation, covariation, modeling, or many other types of analytics and associated visualizations.

To demonstrate its capabilities, here is an example of how a Seeq user can build a fully embedded Add-on to perform partial least squares (PLS) modeling by providing just a single request to the GPT-4 model.

Working with Seeq data in Python

Having some general knowledge of Python and the Seeq Python module (SPy) is necessary to optimize ChatGPT responses because without guidance, the model can make incorrect assumptions.

Most tools for development must ingest data from Seeq to perform analytics. In Python, this is primarily provided by using the spy.search() and/or spy.pull() functions. Both of these are user-friendly, capable of accepting a URL that points to a worksheet containing the signals and timeframe of interest, then outputting a pandas dataframe that contains the relevant data from Seeq.

The spy.pull() function retrieves the time-series data with signal names as column headers. When working with ChatGPT to create code that seamlessly integrates with SPy, it’s important to provide some of these details as context.

Python libraries for creating Add-ons

Keep in mind not every coding objective requires UI components like input text fields, buttons, or associated logic. Sometimes, using ChatGPT to generate code for direct execution in a Python notebook is sufficient, as opposed to creating an embedded custom Add-on application, which is primarily run in Jupyter’s App Mode. The best route to pursue is highly dependent on each use case, and overall end-usage of Seeq tools.

In both of these preceding situations, libraries like sklearn and seaborn are commonly used for advanced analytics and visualizations, offering powerful algorithms to analyze data. To use these and other Python libraries, developers may need to install them in Data Lab, which typically requires running a simple “pip install” command in the notebook or terminal. ChatGPT directly includes this step in its code if asked.

When creating an embedded Add-on, it’s important to understand the role of UI libraries in the development process. These libraries, such as ipywidgets and ipyvuetify, help create the front-end (buttons, selectors, etc.) and associated logic, enabling users to interact with the tool effectively.

In general, it isn’t necessary to know which specific Python library should be used for analytics and visualizations when seeking assistance from ChatGPT. However, if the aim is to create an embedded Add-on, make sure to instruct ChatGPT to use ipywidgets or ipyvuetify for the UI components. Further guidance on this topic is provided in the best practices and example sections that follow.

Best practices for prompt-writing with ChatGPT

To optimize ChatGPT functionality and outputs when creating an Add-on or Python script to interact with data from Seeq, consider the following best practices:

  1. Be clear and concise: Provide specific and detailed instructions to ensure ChatGPT understands your requirements.
  1. Break down complex tasks: Divide your project into specific manageable steps or deliverables the AI can tackle one-by-one.
  1. Include relevant context: Provide necessary background information, such as details of the pandas dataframe structure—often produced by executing spy.search() or spy.pull()—and how the code should functionally run in Jupyter’s App Mode. When creating embedded Add-ons, mention the need to use ipywidgets or ipyvuetify to build front-end components.
  1. Iterate and refine: ChatGPT may not provide the perfect solution or code on the first attempt, so be prepared to modify your prompts or ask for clarification to refine the output. When running provided code that produces an error, ChatGPT is fairly adept at identifying the cause and solution for the error if you provide the associated error message.

Helpful Resources

Security, privacy, and intellectual property considerations

While using AI technology such as ChatGPT can be highly productive, it’s essential to consider security, privacy, and intellectual property. Users must be careful to avoid sharing sensitive information with the AI model.

Summary

ChatGPT is a game-changer for users wanting to amplify their analytics capabilities, and Seeq’s flexibility makes it the perfect deployment mechanism. By bridging the gap between users’ ideas in Seeq and the required development work, ChatGPT in Seeq can help bring any analytics activity to life.

As you integrate ChatGPT into your Seeq workflow, consider security and privacy concerns, and make use of prompt-writing best practices to optimize development results.

*Author’s notes on video example
While it’s incredible that this single prompt successfully created my custom Add-on idea, it should be noted that there are two small errors:

  1. The code ChatGPT produced shows a FutureWarning, which is only relevant if the Python version is upgraded in the future. This warning can be copied and pasted back into ChatGPT to have it respond with the necessary code to suppress the warning.
  1. The message I wanted generated once the button finished loading did not generate. Like above, I simply informed ChatGPT of the error in functionality, and it is usually quick to realize and address the error in its original code.

In addition to addressing the errors above, I could continue working with the model to build additional components and functionality to this Add-on. However, this example is meant to highlight how quickly a simple Add-on idea can be brought to life in Seeq by utilizing ChatGPT. The only true coding I had to do was adjust training_df to be created and returned via spy.pull(url) in the load_data() function. This small detail was made as easy as possible by specifying to ChatGPT: Clicking the button uses the URL to produce a time-series dataframe of variable size called “training_df”. Assume training_df comes from a function called load_data().