Skip to content

Example use cases for Copilot

This topic covers a variety of use cases for transformation pipelines using Copilot. These examples showcase Copilot's capacity to streamline workflows, enhance collaboration, and drive informed decision making with data.


Example 1: Analyzing profit margins for high-margin customers

In this scenario, let's imagine we're working with a company called XYZ.

We've already calculated profit by customer and product, but now we want to delve deeper and determine the profit margin on these items to identify our highest margin customers.

Calculate profit margin

  • Objective: Calculate profit margin and store the result in a new column called "margin."
  • Action: Use Copilot to add a Calculator component for profit margin.
  • Component used: Calculator.
  • Outcome: A new column "margin" is added to the data table.

Process

Our written prompt to Copilot is "Calculate profit margin and store the result in a new column called "margin."" Copilot will then identify the structure of the data and choose the Calculator component. Sampling the data then shows the new "margin" column for profit margins.

Sample data input:

+-----------+---------+--------+------------------+
| Customer  | Product | Profit | Transaction Date |
+-----------+---------+--------+------------------+
| Cust1     | ProdA   | $100   | 2021-11-10       |
| Cust2     | ProdB   | $150   | 2022-01-15       |
| Cust3     | ProdC   | $200   | 2022-03-15       |
| Cust4     | ProdD   | $250   | 2023-05-22       |
+-----------+---------+--------+------------------+

Sample Output after calculating profit margin:

+-----------+---------+--------+--------+------------------+
| Customer  | Product | Profit | Margin | Transaction Date |
+-----------+---------+--------+--------+------------------+
| Cust1     | ProdA   | $100   | 25%    | 2021-11-10       |
| Cust2     | ProdB   | $150   | 30%    | 2022-01-15       |
| Cust3     | ProdC   | $200   | 65%    | 2022-03-15       |
| Cust4     | ProdD   | $250   | 70%    | 2023-05-22       |
+-----------+---------+--------+--------+------------------+

Filter high margin customers

  • Objective: Filter rows where the margin is higher than 60%.
  • Action: Use Copilot to apply a Filter component for high margin customers.
  • Component used: Filter.
  • Outcome: Rows with a margin higher than 60% are filtered and kept.

Process

Our written prompt to Copilot is "Filter rows where the margin is higher than 60%." Copilot then chooses a Filter component and then prepares this component to ensure that only high-margin customers are shown when the table is sampled.

Sample Output after filtering high margin customers:

+-----------+---------+--------+--------+------------------+
| Customer  | Product | Profit | Margin | Transaction Date |
+-----------+---------+--------+--------+------------------+
| Cust3     | ProdC   | $200   | 65%    | 2022-03-15       |
| Cust4     | ProdD   | $250   | 70%    | 2023-05-22       |
+-----------+---------+--------+--------+------------------+

Filter recent transactions

  • Objective: Keep only transactions from 2022 onwards.
  • Action: Use Copilot to apply a date via a Filter component for recent transactions.
  • Component used: Filter.
  • Outcome: Transactions from 2022 onwards are filtered and kept.

Process

Our prompt to Copilot is "Filter out any transactions that are not from 2022 and onwards." Copilot chooses a Filter component and filters out any rows from before 2022.

Sample Output after filtering recent transactions:

+-----------+---------+--------+--------+------------------+
| Customer  | Product | Profit | Margin | Transaction Date |
+-----------+---------+--------+--------+------------------+
| Cust3     | ProdC   | $200   | 65%    | 2022-03-15       |
| Cust4     | ProdD   | $250   | 70%    | 2023-05-22       |
+-----------+---------+--------+--------+------------------+

Write results to a view

  • Objective: Write the results to a view named "high margin customers."
  • Action: Use Copilot to add a Create View component for writing results to a view.
  • Component used: Create View.
  • Outcome: Filtered results are written to a view called "high margin customers."

Process

Our prompt to Copilot is "Write these results to a new view named "high margin customers". Copilot chooses the Create View component and writes the data to the new view. Our results are ready for analysis and sharing.

Sample Output in view "high margin customers":

+-----------+---------+--------+--------+------------------+
| Customer  | Product | Profit | Margin | Transaction Date |
+-----------+---------+--------+--------+------------------+
| Cust3     | ProdC   | $200   | 65%    | 2022-03-15       |
| Cust4     | ProdD   | $250   | 70%    | 2023-05-22       |
+-----------+---------+--------+--------+------------------+

Example 2: Filtering Netflix movie data

In another scenario, let's explore how Copilot can assist us in filtering Netflix movie data to identify top-rated movies for viewing.

Rank films by rating

  • Objective: Rank all films by their rating.
  • Action: Use Copilot to sort the data by rating.
  • Component Used: Rank
  • Outcome: The data is sorted in descending order based on each film's rating.

Process

Our prompt to Copilot is "Rank movies by their rating in descending order." Copilot then chooses a Rank component and ranks the movies in descending order based on the "Rating" column.

Sample Output after ranking films by rating:

+-------------+---------------+-------+-------+
| Movie Title | Release Year  | Genre | Rating|
+-------------+---------------+-------+-------+
| Movie A     | 2023          | Drama | 8.1   |
| Movie D     | 2021          | Drama | 8.0   |
| Movie B     | 2022          | Action| 7.5   |
| Movie C     | 2023          | Comedy| 6.9   |
+-------------+---------------+-------+-------+

Filter movies by year

  • Objective: Filter movies from the year 2023 only.
  • Action: Use Copilot to filter the data by the specified year.
  • Component used: Filter.
  • Outcome: The data is filtered to show only movies released in 2023.

Process

Our prompt to Copilot is "Filter movies to only show movies from the year 2023." Copilot selects the required components and parameterizes them to only show movies from 2023.

Sample data input:

+-------------+--------------+-------+-------+
| Movie Title | Release Year | Genre | Rating|
+-------------+--------------+-------+-------+
| Movie A     | 2023         | Drama | 8.1   |
| Movie B     | 2022         | Action| 7.5   |
| Movie C     | 2023         | Comedy| 6.9   |
| Movie D     | 2021         | Drama | 8.0   |
+-------------+--------------+-------+-------+

Sample Output after filtering movies from 2023:

+-------------+---------------+-------+-------+
| Movie Title | Release Year  | Genre | Rating|
+-------------+---------------+-------+-------+
| Movie A     | 2023          | Drama | 8.1   |
| Movie C     | 2023          | Comedy| 6.9   |
+-------------+---------------+-------+-------+

Example 3: Analyzing customer feedback with Copilot and Snowflake Cortex components

In this scenario, we want to use Snowflake Cortex components to manage and respond to customer reviews. This example showcases translating reviews, performing sentiment analysis on those reviews, and generating automated responses based on sentiment scores.

Initial setup

First we provide Copilot with some context: "You are a data engineer working for a hotel company that collects customer reviews for the hotel's booking system."

Our review data is stored in a table, and the reviews are written in French.

Sample Data Input:

+-----------+-----------------------------------------------------+
| User      | Review_text                                         |
+-----------+-----------------------------------------------------+
| User A    | "Produit excellent, très convivial !"               |
| User B    | "A besoin d'amélioration, trop de bugs."            |
| User A    | "J'aimerais voir plus de fonctionnalités ajoutées." |
| User C    | "Excellent service client."                         |
+-----------+-----------------------------------------------------+

Translate reviews

  • Objective: Translate customer reviews from French to English.
  • Action: Use Copilot to automatically identify and apply the appropriate transformation logic.
  • Component Used: Cortex Translate.
  • Outcome: A new column is added to the data table containing the translated reviews.

Process

Our prompt to Copilot is "Translate the review_text rows from French to English. Drop the input column." Copilot selects the Cortex Translate component and applies the logic to translate the input text from French to English. Sampling the data shows a new column with translated text in English. As per our prompt, Copilot has not included the input (French) column.

Sample output after translation:

+-----------+-------------------------------------------+
| User      | en_Review_text                            |
+-----------+-------------------------------------------+
| User A    | "Great product, very user-friendly!"      |
| User B    | "Needs improvement, too many bugs."       |
| User C    | "Would love to see more features added."  |
| User D    | "Excellent customer support."             |
+-----------+-------------------------------------------+

Sentiment analysis

Objective: Determine the sentiment of the reviews to gauge customer satisfaction. Action: Use Copilot to apply a sentiment analysis transformation. Component Used: Cortex Sentiment. Outcome: A new column is added with sentiment scores for each review.

Process

Our prompt to Copilot is "Calculate the sentiment score of each review in "en_Review_text"." Copilot selects the Cortex Sentiment component and applies logic to calculate sentiment by analyzing each review. Sampling the data shows sentiment scores, indicating whether reviews are positive (1), negative (-1), or neutral (0).

Sample Output After Sentiment Analysis:

+-----------+----------------------------------------------------------+
| en_Review_text                            | sentiment_en_Review_text |
+-----------+-------------------------------|--------------------------+
|"Great product, very user-friendly!"       | 0.86195534               |
| "Needs improvement, too many bugs."       | -0.075002715             |
| "Would love to see more features added."  | 0.31447184               |
| "Excellent customer support."             | 0.78951025               |
+-----------+----------------------------------------------------------+

Automated apology email generation

Objective: Automatically generate apology emails for negative reviews to improve customer service. Action: Use Copilot to create a condition-based response mechanism. Components Used: Filter, Cortex Completions. Outcome: Automated generation of personalized apology emails for reviews with low sentiment scores.

Process

Our prompt to Copilot is "For sentiment scores lower than 0, generate a paragraph to apologize to the customer based on the content of their review." Copilot adds a Filter component to filter rows where the sentiment score is less than 0, then Copilot uses a Cortex Completions component to invoke a large language model (LLM) to craft apology emails based on user reviews.

Sample output after apology generation:

+-------------------------------------+--------------------------+--------------------+
| en_Review_text                      | sentiment_en_Review_text | completion_result  |
+-------------------------------------+--------------------------+--------------------+
| "Needs improvement, too many bugs." | -0.07575456              | "Dear customer..." |
+-------------------------------------+--------------------------+--------------------+

Example data returned from Cortex Completion (too long to display in table):

{
choices: [
{
messages: " Dear valued customer,\n\nI want to start by saying thank you for taking the time to share your feedback with us. We are sorry to hear that you have encountered bugs while using our product, and we understand how frustrating it can be when things don't go as planned. Our team is dedicated to providing the best possible experience for our customers, and we take all feedback seriously. We would like to assure you that we are constantly working on improving our product and services, and your feedback has been noted. We would like to offer you a complimentary service to make up for the inconvenience you have experienced. Contact our customer service team for more information. Thank you for your patience and understanding.\n\nSincerely,\n[Your Name]\nCustomer Service Representative."
}
],
created: 1717410165,
model: "llama2-70b-chat",
usage: {
completion_tokens: 170,
prompt_tokens: 78,
total_tokens: 248
}
}

Example 3 conclusion

With Copilot and Snowflake Cortex components, you can streamline the analysis and management of customer reviews, ensuring prompt and appropriate responses that enhance customer satisfaction and operational efficiency.