Skip to content

Commit e443fd1

Browse files
committed
update samples from Release-6 as a part of 1.1.5rc0 SDK stable release
1 parent 2165cf3 commit e443fd1

File tree

17 files changed

+331
-30
lines changed

17 files changed

+331
-30
lines changed

configuration.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"source": [
104104
"import azureml.core\n",
105105
"\n",
106-
"print(\"This notebook was created using version 1.1.2rc0 of the Azure ML SDK\")\n",
106+
"print(\"This notebook was created using version 1.1.5rc0 of the Azure ML SDK\")\n",
107107
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
108108
]
109109
},

how-to-use-azureml/automated-machine-learning/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jupyter notebook
144144
- Dataset: forecasting for a bike-sharing
145145
- Example of training an automated ML forecasting model on multiple time-series
146146

147-
- [automl-forecasting-function.ipynb](forecasting-high-frequency/automl-forecasting-function.ipynb)
147+
- [auto-ml-forecasting-function.ipynb](forecasting-high-frequency/auto-ml-forecasting-function.ipynb)
148148
- Example of training an automated ML forecasting model on multiple time-series
149149

150150
- [auto-ml-forecasting-beer-remote.ipynb](forecasting-beer-remote/auto-ml-forecasting-beer-remote.ipynb)

how-to-use-azureml/automated-machine-learning/automl_env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies:
2121
- pip:
2222
# Required packages for AzureML execution, history, and data preparation.
2323
- azureml-defaults
24+
- azureml-dataprep[pandas]
2425
- azureml-train-automl
2526
- azureml-train
2627
- azureml-widgets

how-to-use-azureml/automated-machine-learning/automl_env_mac.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies:
2222
- pip:
2323
# Required packages for AzureML execution, history, and data preparation.
2424
- azureml-defaults
25+
- azureml-dataprep[pandas]
2526
- azureml-train-automl
2627
- azureml-train
2728
- azureml-widgets
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: automl-forecasting-function
1+
name: auto-ml-forecasting-function
22
dependencies:
33
- fbprophet==0.5
44
- py-xgboost<=0.80

how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dependencies:
44
- py-xgboost<=0.80
55
- pip:
66
- azureml-sdk
7+
- pandas==0.23.4
78
- azureml-train-automl
89
- azureml-widgets
910
- matplotlib

how-to-use-azureml/automated-machine-learning/regression-hardware-performance-explanation-and-featurization/auto-ml-regression-hardware-performance-explanation-and-featurization.ipynb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,7 @@
532532
"cell_type": "markdown",
533533
"metadata": {},
534534
"source": [
535-
"#### Create conda configuration for model explanations experiment\n",
536-
"We need `azureml-explain-model`, `azureml-train-automl` and `azureml-core` packages for computing model explanations for your AutoML model on remote compute."
535+
"#### Create conda configuration for model explanations experiment from automl_run object"
537536
]
538537
},
539538
{
@@ -552,13 +551,9 @@
552551
"# Set compute target to AmlCompute\n",
553552
"conda_run_config.target = compute_target\n",
554553
"conda_run_config.environment.docker.enabled = True\n",
555-
"azureml_pip_packages = [\n",
556-
" 'azureml-train-automl', 'azureml-core', 'azureml-explain-model'\n",
557-
"]\n",
558554
"\n",
559555
"# specify CondaDependencies obj\n",
560-
"conda_run_config.environment.python.conda_dependencies = CondaDependencies.create(\n",
561-
" pip_packages=azureml_pip_packages)"
556+
"conda_run_config.environment.python.conda_dependencies = automl_run.get_environment().python.conda_dependencies"
562557
]
563558
},
564559
{

how-to-use-azureml/automated-machine-learning/regression/auto-ml-regression.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: auto-ml-regression
22
dependencies:
33
- pip:
44
- azureml-sdk
5+
- pandas==0.23.4
56
- azureml-train-automl
67
- azureml-widgets
78
- matplotlib

how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb

Lines changed: 93 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,6 @@
341341
"metadata": {},
342342
"outputs": [],
343343
"source": [
344-
"import json\n",
345-
"\n",
346-
"\n",
347344
"input_payload = json.dumps({\n",
348345
" 'data': [\n",
349346
" [ 0.03807591, 0.05068012, 0.06169621, 0.02187235, -0.0442235,\n",
@@ -376,16 +373,101 @@
376373
"cell_type": "markdown",
377374
"metadata": {},
378375
"source": [
379-
"### Model profiling\n",
376+
"### Model Profiling\n",
380377
"\n",
381-
"You can also take advantage of the profiling feature to estimate CPU and memory requirements for models.\n",
378+
"Profile your model to understand how much CPU and memory the service, created as a result of its deployment, will need. Profiling returns information such as CPU usage, memory usage, and response latency. It also provides a CPU and memory recommendation based on the resource usage. You can profile your model (or more precisely the service built based on your model) on any CPU and/or memory combination where 0.1 <= CPU <= 3.5 and 0.1GB <= memory <= 15GB. If you do not provide a CPU and/or memory requirement, we will test it on the default configuration of 3.5 CPU and 15GB memory.\n",
382379
"\n",
383-
"```python\n",
384-
"profile = Model.profile(ws, \"profilename\", [model], inference_config, test_sample)\n",
385-
"profile.wait_for_profiling(True)\n",
386-
"profiling_results = profile.get_results()\n",
387-
"print(profiling_results)\n",
388-
"```"
380+
"In order to profile your model you will need:\n",
381+
"- a registered model\n",
382+
"- an entry script\n",
383+
"- an inference configuration\n",
384+
"- a single column tabular dataset, where each row contains a string representing sample request data sent to the service.\n",
385+
"\n",
386+
"At this point we only support profiling of services that expect their request data to be a string, for example: string serialized json, text, string serialized image, etc. The content of each row of the dataset (string) will be put into the body of the HTTP request and sent to the service encapsulating the model for scoring.\n",
387+
"\n",
388+
"Below is an example of how you can construct an input dataset to profile a service which expects its incoming requests to contain serialized json. In this case we created a dataset based one hundred instances of the same request data. In real world scenarios however, we suggest that you use larger datasets with various inputs, especially if your model resource usage/behavior is input dependent."
389+
]
390+
},
391+
{
392+
"cell_type": "code",
393+
"execution_count": null,
394+
"metadata": {},
395+
"outputs": [],
396+
"source": [
397+
"from azureml.core import Datastore\n",
398+
"from azureml.core.dataset import Dataset\n",
399+
"from azureml.data import dataset_type_definitions\n",
400+
"\n",
401+
"\n",
402+
"# create a string that can be utf-8 encoded and\n",
403+
"# put in the body of the request\n",
404+
"serialized_input_json = json.dumps({\n",
405+
" 'data': [\n",
406+
" [ 0.03807591, 0.05068012, 0.06169621, 0.02187235, -0.0442235,\n",
407+
" -0.03482076, -0.04340085, -0.00259226, 0.01990842, -0.01764613]\n",
408+
" ]\n",
409+
"})\n",
410+
"dataset_content = []\n",
411+
"for i in range(100):\n",
412+
" dataset_content.append(serialized_input_json)\n",
413+
"dataset_content = '\\n'.join(dataset_content)\n",
414+
"file_name = 'sample_request_data.txt'\n",
415+
"f = open(file_name, 'w')\n",
416+
"f.write(dataset_content)\n",
417+
"f.close()\n",
418+
"\n",
419+
"# upload the txt file created above to the Datastore and create a dataset from it\n",
420+
"data_store = Datastore.get_default(ws)\n",
421+
"data_store.upload_files(['./' + file_name], target_path='sample_request_data')\n",
422+
"datastore_path = [(data_store, 'sample_request_data' +'/' + file_name)]\n",
423+
"sample_request_data = Dataset.Tabular.from_delimited_files(\n",
424+
" datastore_path,\n",
425+
" separator='\\n',\n",
426+
" infer_column_types=True,\n",
427+
" header=dataset_type_definitions.PromoteHeadersBehavior.NO_HEADERS)\n",
428+
"sample_request_data = sample_request_data.register(workspace=ws,\n",
429+
" name='diabetes_sample_request_data',\n",
430+
" create_new_version=True)"
431+
]
432+
},
433+
{
434+
"cell_type": "markdown",
435+
"metadata": {},
436+
"source": [
437+
"Now that we have an input dataset we are ready to go ahead with profiling. In this case we are testing the previously introduced sklearn regression model on 1 CPU and 0.5 GB memory. The memory usage and recommendation presented in the result is measured in Gigabytes. The CPU usage and recommendation is measured in CPU cores."
438+
]
439+
},
440+
{
441+
"cell_type": "code",
442+
"execution_count": null,
443+
"metadata": {},
444+
"outputs": [],
445+
"source": [
446+
"from datetime import datetime\n",
447+
"\n",
448+
"\n",
449+
"environment = Environment('my-sklearn-environment')\n",
450+
"environment.python.conda_dependencies = CondaDependencies.create(pip_packages=[\n",
451+
" 'azureml-defaults',\n",
452+
" 'inference-schema[numpy-support]',\n",
453+
" 'joblib',\n",
454+
" 'numpy',\n",
455+
" 'scikit-learn'\n",
456+
"])\n",
457+
"inference_config = InferenceConfig(entry_script='score.py', environment=environment)\n",
458+
"# if cpu and memory_in_gb parameters are not provided\n",
459+
"# the model will be profiled on default configuration of\n",
460+
"# 3.5CPU and 15GB memory\n",
461+
"profile = Model.profile(ws,\n",
462+
" 'rgrsn-%s' % datetime.now().strftime('%m%d%Y-%H%M%S'),\n",
463+
" [model],\n",
464+
" inference_config,\n",
465+
" input_dataset=sample_request_data,\n",
466+
" cpu=1.0,\n",
467+
" memory_in_gb=0.5)\n",
468+
"\n",
469+
"profile.wait_for_completion(True)\n",
470+
"details = profile.get_details()"
389471
]
390472
},
391473
{

0 commit comments

Comments
 (0)