|
| 1 | +--- |
| 2 | +lab: |
| 3 | + title: 'Lab 17 – Design a machine learning solution case study' |
| 4 | + module: Design a machine learning training solution |
| 5 | + description: "You'll work through a Contoso Retail case study to design a machine learning training solution for a product recommendation system, making decisions about data strategy, service selection, compute resources, and deployment. By the end, you'll understand how to make informed machine learning design choices that balance cost, performance, complexity, and team skills." |
| 6 | + duration: 15 # duration in minutes |
| 7 | + level: 300 # 100 basic concepts, 200 foundations, 300 practical usage, 400 advanced scenarios, 500 expert design |
| 8 | + islab: no # if this is not a lab that should be listed in the catalog, set to false |
| 9 | + status: 'in-development' # in-development or released |
| 10 | + targetDate: '2099-01-01' # Set to the future date when you expect an in-development lab to be released |
| 11 | +--- |
| 12 | + |
| 13 | +# Design a machine learning solution - Case study |
| 14 | + |
| 15 | +**Estimated Time: 15 minutes** |
| 16 | + |
| 17 | +> [!NOTE] |
| 18 | +> To complete this exercise, read the case study carefully. Apply the design principles you've learned throughout this module to make informed decisions. At the end, you'll test your understanding by answering knowledge check questions. |
| 19 | +
|
| 20 | +Welcome to Contoso Retail! You've been hired as the **lead data scientist** to help us design a machine learning training solution. |
| 21 | + |
| 22 | +## Understand the problem |
| 23 | + |
| 24 | +At Contoso Retail, we operate both physical stores and an e-commerce platform. We want to build a **product recommendation system** that suggests items to customers based on their browsing and purchase history. |
| 25 | + |
| 26 | +Our goal is to increase customer engagement and sales by showing personalized product recommendations: |
| 27 | + |
| 28 | +- In our **mobile app**, customers should see recommendations immediately when they view a product. |
| 29 | +- For our **weekly email campaign**, we want to include the top 5 recommended products for each of our 2 million customers. |
| 30 | + |
| 31 | +Our data engineering team has been collecting customer interaction data for the past two years, including: |
| 32 | + |
| 33 | +- Browsing history (products viewed, time spent) |
| 34 | +- Purchase history (items bought, purchase dates, amounts) |
| 35 | +- Customer demographics (age, location, preferences) |
| 36 | +- Product catalog (categories, prices, descriptions, images) |
| 37 | + |
| 38 | +The data is currently stored in multiple systems: |
| 39 | + |
| 40 | +- Transactional data in Azure SQL Database (updated in real time) |
| 41 | +- Clickstream data from our website stored as JSON files in Azure Blob Storage (logged every hour) |
| 42 | +- Product images stored in Azure Blob Storage |
| 43 | +- Customer profiles in our CRM system (Dynamics 365) |
| 44 | + |
| 45 | +We need your help deciding **how to design the machine learning training solution** to build this recommendation system. |
| 46 | + |
| 47 | +## Consider the requirements |
| 48 | + |
| 49 | +As you design the solution, think about these key areas. |
| 50 | + |
| 51 | +### Data ingestion and preparation |
| 52 | + |
| 53 | +- **Consider the data sources**: We have data in Azure SQL Database, Blob Storage (JSON files), Blob Storage (images), and Dynamics 365. How should we consolidate this data? |
| 54 | +- **Consider the data format**: The data is in different formats (structured, semi-structured, and unstructured). What format should we use for training? |
| 55 | +- **Consider the data pipeline**: Should we build a data ingestion pipeline? If so, how often should it run? |
| 56 | + |
| 57 | +### Machine learning task and service |
| 58 | + |
| 59 | +- **Consider the machine learning task**: What type of machine learning task is this? Classification, regression, recommendation, or something else? |
| 60 | +- **Consider the service**: Should we use Azure Machine Learning, Azure Databricks, Microsoft Fabric, or Microsoft Foundry? What factors influence this choice? |
| 61 | +- **Consider existing skills**: Our team has strong Python experience but limited Spark knowledge. How does this affect our choice? |
| 62 | + |
| 63 | +### Compute resources |
| 64 | + |
| 65 | +- **Consider the data size**: We have 2 million customers and millions of product interactions. What compute type is appropriate? |
| 66 | +- **Consider the model complexity**: Recommendation systems can be simple (collaborative filtering) or complex (deep learning). How does this affect compute needs? |
| 67 | +- **Consider cost**: We have a limited budget for this initial phase. Should we start with CPU or GPU? General purpose or memory optimized? |
| 68 | + |
| 69 | +### Deployment requirements |
| 70 | + |
| 71 | +- **Consider the deployment types**: We need both real-time recommendations (mobile app) and batch predictions (email campaign). How should we handle these different needs? |
| 72 | +- **Consider the frequency**: Mobile app recommendations need to be instant. Email campaigns are sent weekly. Should we use different endpoints? |
| 73 | +- **Consider the scale**: Our app has 100,000 active daily users. Our email campaign targets 2 million customers. How does scale affect our deployment decisions? |
| 74 | + |
| 75 | +## Your task |
| 76 | + |
| 77 | +Based on these requirements, you need to make design decisions about: |
| 78 | + |
| 79 | +1. **Data strategy**: How will you ingest, transform, and store the data for training? |
| 80 | +2. **Service selection**: Which Azure service(s) will you use for training, and why? |
| 81 | +3. **Compute strategy**: What compute resources will you provision for training? |
| 82 | +4. **Deployment approach**: How will you handle both real-time and batch prediction requirements? |
| 83 | + |
| 84 | +Think through each decision carefully, considering trade-offs between cost, performance, complexity, and team capabilities. The knowledge check questions test your ability to make informed design choices based on this scenario. |
| 85 | + |
| 86 | +## Knowledge check |
| 87 | + |
| 88 | +Answer the following questions based on the Contoso Retail case study. Select an answer for each question, then expand **Show answer** to check your reasoning. |
| 89 | + |
| 90 | +**1. Based on the Contoso Retail case study, what data ingestion strategy would be most appropriate for consolidating data from Azure SQL Database, Blob Storage (JSON), and Dynamics 365?** |
| 91 | + |
| 92 | +- Manually export data from each source and combine in Excel before training. |
| 93 | +- Create an ETL pipeline using Azure Synapse Analytics to extract, transform, and load data into a unified storage layer like Azure Data Lake Storage. |
| 94 | +- Keep data in separate sources and connect directly to each during model training. |
| 95 | + |
| 96 | +<details> |
| 97 | +<summary>Show answer</summary> |
| 98 | + |
| 99 | +**Create an ETL pipeline using Azure Synapse Analytics to extract, transform, and load data into a unified storage layer like Azure Data Lake Storage.** |
| 100 | + |
| 101 | +The data is spread across structured, semi-structured, and unstructured sources that update on different schedules. An automated ETL pipeline consolidates these sources into a single, training-ready layer. Manual export doesn't scale to millions of interactions, and connecting directly to each source during training adds latency and complexity. |
| 102 | + |
| 103 | +</details> |
| 104 | + |
| 105 | +**2. For the Contoso Retail recommendation system, which Azure service would be most suitable given the team's Python experience and the need to train on large-scale customer interaction data?** |
| 106 | + |
| 107 | +- Microsoft Foundry, because it provides pre-built recommendation models. |
| 108 | +- Azure Machine Learning, because it supports the Python SDK, handles large datasets, and provides comprehensive tools for custom model training. |
| 109 | +- Azure Databricks, because it's required for any large-scale machine learning. |
| 110 | + |
| 111 | +<details> |
| 112 | +<summary>Show answer</summary> |
| 113 | + |
| 114 | +**Azure Machine Learning, because it supports the Python SDK, handles large datasets, and provides comprehensive tools for custom model training.** |
| 115 | + |
| 116 | +The team has strong Python skills but limited Spark knowledge, which makes Azure Machine Learning a better fit than Azure Databricks. Azure Databricks is Spark-based and isn't required for all large-scale machine learning. Microsoft Foundry focuses on generative AI rather than custom recommendation training. |
| 117 | + |
| 118 | +</details> |
| 119 | + |
| 120 | +**3. Considering Contoso Retail needs both real-time recommendations (mobile app) and batch predictions (weekly email campaign), what deployment strategy should they implement?** |
| 121 | + |
| 122 | +- Deploy two separate models: a real-time endpoint for the mobile app and a batch endpoint for the email campaign. |
| 123 | +- Deploy only a real-time endpoint and call it 2 million times for the email campaign. |
| 124 | +- Deploy only a batch endpoint and accept 5-10 minute delays for mobile app recommendations. |
| 125 | + |
| 126 | +<details> |
| 127 | +<summary>Show answer</summary> |
| 128 | + |
| 129 | +**Deploy two separate models: a real-time endpoint for the mobile app and a batch endpoint for the email campaign.** |
| 130 | + |
| 131 | +The two scenarios have different latency and throughput needs. A real-time (online) endpoint delivers instant recommendations in the mobile app, while a batch endpoint efficiently scores 2 million customers for the weekly email. Forcing one endpoint type to handle both leads to either excessive cost or unacceptable latency. |
| 132 | + |
| 133 | +</details> |
| 134 | + |
| 135 | +**4. What compute resource would be most appropriate for training the initial Contoso Retail recommendation model, given the 2 million customer dataset and budget constraints?** |
| 136 | + |
| 137 | +- Start with CPU general-purpose compute, monitor performance, and scale to memory-optimized or GPU if needed. |
| 138 | +- Immediately provision the largest GPU memory-optimized compute to ensure fast training. |
| 139 | +- Use only local development machines to minimize Azure costs. |
| 140 | + |
| 141 | +<details> |
| 142 | +<summary>Show answer</summary> |
| 143 | + |
| 144 | +**Start with CPU general-purpose compute, monitor performance, and scale to memory-optimized or GPU if needed.** |
| 145 | + |
| 146 | +With a limited initial budget, start with cost-effective CPU general-purpose compute and scale up only when the model complexity or training time justifies it. Provisioning the largest GPU upfront wastes budget, and local machines can't handle the scale of 2 million customers and millions of interactions. |
| 147 | + |
| 148 | +</details> |
0 commit comments