Skip to content

Commit 9788d19

Browse files
authored
Merge pull request Azure#1799 from Azure/release_update/Release-155
update samples from Release-155 as a part of SDK release
2 parents 25f407f + 387e43a commit 9788d19

File tree

12 files changed

+195
-0
lines changed

12 files changed

+195
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- python
5+
products:
6+
- azure-machine-learning
7+
description: Tutorial showing how to solve a complex machine learning time series forecasting problems at scale by using Azure Automated ML and Many Models solution accelerator.
8+
---
9+
10+
![Many Models Solution Accelerator Banner](images/mmsa.png)
11+
# Many Models Solution Accelerator
12+
13+
<!--
14+
Guidelines on README format: https://review.docs.microsoft.com/help/onboard/admin/samples/concepts/readme-template?branch=master
15+
16+
Guidance on onboarding samples to docs.microsoft.com/samples: https://review.docs.microsoft.com/help/onboard/admin/samples/process/onboarding?branch=master
17+
18+
Taxonomies for products and languages: https://review.docs.microsoft.com/new-hope/information-architecture/metadata/taxonomies?branch=master
19+
-->
20+
21+
In the real world, many problems can be too complex to be solved by a single machine learning model. Whether that be predicting sales for each individual store, building a predictive maintanence model for hundreds of oil wells, or tailoring an experience to individual users, building a model for each instance can lead to improved results on many machine learning problems.
22+
23+
This Pattern is very common across a wide variety of industries and applicable to many real world use cases. Below are some examples we have seen where this pattern is being used.
24+
25+
- Energy and utility companies building predictive maintenance models for thousands of oil wells, hundreds of wind turbines or hundreds of smart meters
26+
27+
- Retail organizations building workforce optimization models for thousands of stores, campaign promotion propensity models, Price optimization models for hundreds of thousands of products they sell
28+
29+
- Restaurant chains building demand forecasting models across thousands of restaurants 
30+
31+
- Banks and financial institutes building models for cash replenishment for ATM Machine and for several ATMs or building personalized models for individuals
32+
33+
- Enterprises building revenue forecasting models at each division level
34+
35+
- Document management companies building text analytics and legal document search models per each state
36+
37+
Azure Machine Learning (AML) makes it easy to train, operate, and manage hundreds or even thousands of models. This repo will walk you through the end to end process of creating a many models solution from training to scoring to monitoring.
38+
39+
## Prerequisites
40+
41+
To use this solution accelerator, all you need is access to an [Azure subscription](https://azure.microsoft.com/free/) and an [Azure Machine Learning Workspace](https://docs.microsoft.com/azure/machine-learning/how-to-manage-workspace) that you'll create below.
42+
43+
While it's not required, a basic understanding of Azure Machine Learning will be helpful for understanding the solution. The following resources can help introduce you to AML:
44+
45+
1. [Azure Machine Learning Overview](https://azure.microsoft.com/services/machine-learning/)
46+
2. [Azure Machine Learning Tutorials](https://docs.microsoft.com/azure/machine-learning/tutorial-1st-experiment-sdk-setup)
47+
3. [Azure Machine Learning Sample Notebooks on Github](https://github.com/Azure/azureml-examples)
48+
49+
## Getting started
50+
51+
### 1. Deploy Resources
52+
53+
Start by deploying the resources to Azure. The button below will deploy Azure Machine Learning and its related resources:
54+
55+
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2Fsolution-accelerator-many-models%2Fmaster%2Fazuredeploy.json" target="_blank">
56+
<img src="http://azuredeploy.net/deploybutton.png"/>
57+
</a>
58+
59+
### 2. Configure Development Environment
60+
61+
Next you'll need to configure your [development environment](https://docs.microsoft.com/azure/machine-learning/how-to-configure-environment) for Azure Machine Learning. We recommend using a [Compute Instance](https://docs.microsoft.com/azure/machine-learning/how-to-configure-environment#compute-instance) as it's the fastest way to get up and running.
62+
63+
### 3. Run Notebooks
64+
65+
Once your development environment is set up, run through the Jupyter Notebooks sequentially following the steps outlined. By the end, you'll know how to train, score, and make predictions using the many models pattern on Azure Machine Learning.
66+
67+
![Sequence of Notebooks](./images/mmsa-overview.png)
68+
69+
70+
## Contents
71+
72+
In this repo, you'll train and score a forecasting model for each orange juice brand and for each store at a (simulated) grocery chain. By the end, you'll have forecasted sales by using up to 11,973 models to predict sales for the next few weeks.
73+
74+
The data used in this sample is simulated based on the [Dominick's Orange Juice Dataset](http://www.cs.unitn.it/~taufer/QMMA/L10-OJ-Data.html#(1)), sales data from a Chicago area grocery store.
75+
76+
<img src="images/Flow_map.png" width="1000">
77+
78+
### Using Automated ML to train the models:
79+
80+
The [`auto-ml-forecasting-many-models.ipynb`](./auto-ml-forecasting-many-models.ipynb) noteboook is a guided solution accelerator that demonstrates steps from data preparation, to model training, and forecasting on train models as well as operationalizing the solution.
81+
82+
## How-to-videos
83+
84+
Watch these how-to-videos for a step by step walk-through of the many model solution accelerator to learn how to setup your models using Automated ML.
85+
86+
### Automated ML
87+
88+
[![Watch the video](https://media.giphy.com/media/dWUKfameudyNGRnp1t/giphy.gif)](https://channel9.msdn.com/Shows/Docs-AI/Building-Large-Scale-Machine-Learning-Forecasting-Models-using-Azure-Machine-Learnings-Automated-ML)
89+
90+
## Key concepts
91+
92+
### ParallelRunStep
93+
94+
[ParallelRunStep](https://docs.microsoft.com/en-us/python/api/azureml-pipeline-steps/azureml.pipeline.steps.parallel_run_step.parallelrunstep?view=azure-ml-py) enables the parallel training of models and is commonly used for batch inferencing. This [document](https://docs.microsoft.com/azure/machine-learning/how-to-use-parallel-run-step) walks through some of the key concepts around ParallelRunStep.
95+
96+
### Pipelines
97+
98+
[Pipelines](https://docs.microsoft.com/azure/machine-learning/concept-ml-pipelines) allow you to create workflows in your machine learning projects. These workflows have a number of benefits including speed, simplicity, repeatability, and modularity.
99+
100+
### Automated Machine Learning
101+
102+
[Automated Machine Learning](https://docs.microsoft.com/azure/machine-learning/concept-automated-ml) also referred to as automated ML or AutoML, is the process of automating the time consuming, iterative tasks of machine learning model development. It allows data scientists, analysts, and developers to build ML models with high scale, efficiency, and productivity all while sustaining model quality.
103+
104+
### Other Concepts
105+
106+
In additional to ParallelRunStep, Pipelines and Automated Machine Learning, you'll also be working with the following concepts including [workspace](https://docs.microsoft.com/azure/machine-learning/concept-workspace), [datasets](https://docs.microsoft.com/azure/machine-learning/concept-data#datasets), [compute targets](https://docs.microsoft.com/azure/machine-learning/concept-compute-target#train), [python script steps](https://docs.microsoft.com/python/api/azureml-pipeline-steps/azureml.pipeline.steps.python_script_step.pythonscriptstep?view=azure-ml-py), and [Azure Open Datasets](https://azure.microsoft.com/services/open-datasets/).
107+
108+
## Contributing
109+
110+
This project welcomes contributions and suggestions. To learn more visit the [contributing](../../../CONTRIBUTING.md) section.
111+
112+
Most contributions require you to agree to a Contributor License Agreement (CLA)
113+
declaring that you have the right to, and actually do, grant us
114+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
115+
116+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
117+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
118+
provided by the bot. You will only need to do this once across all repos using our CLA.
119+
120+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
121+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
122+
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
32.4 KB
Loading
306 KB
Loading
2.63 MB
Loading
106 KB
Loading
158 KB
Loading
79.9 KB
Loading
68.5 KB
Loading
631 KB
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from pathlib import Path
2+
from azureml.core import Run
3+
4+
import argparse
5+
import os
6+
7+
8+
def main(args):
9+
output = Path(args.output)
10+
output.mkdir(parents=True, exist_ok=True)
11+
12+
run_context = Run.get_context()
13+
input_path = run_context.input_datasets["train_10_models"]
14+
15+
for file_name in os.listdir(input_path):
16+
input_file = os.path.join(input_path, file_name)
17+
with open(input_file, "r") as f:
18+
content = f.read()
19+
20+
# Apply any data pre-processing techniques here
21+
22+
output_file = os.path.join(output, file_name)
23+
with open(output_file, "w") as f:
24+
f.write(content)
25+
26+
27+
def my_parse_args():
28+
parser = argparse.ArgumentParser("Test")
29+
30+
parser.add_argument("--input", type=str)
31+
parser.add_argument("--output", type=str)
32+
33+
args = parser.parse_args()
34+
return args
35+
36+
37+
if __name__ == "__main__":
38+
args = my_parse_args()
39+
main(args)

0 commit comments

Comments
 (0)