mirror of
https://github.com/Azure/MachineLearningNotebooks.git
synced 2025-12-20 01:27:06 -05:00
224 lines
7.9 KiB
Plaintext
224 lines
7.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
|
|
"\n",
|
|
"Licensed under the MIT License."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# AutoML 00. Configuration\n",
|
|
"\n",
|
|
"In this example you will create an Azure Machine Learning `Workspace` object and initialize your notebook directory to easily reload this object from a configuration file. Typically you will only need to run this once per notebook directory, and all other notebooks in this directory or any sub-directories will automatically use the settings you indicate here.\n",
|
|
"\n",
|
|
"\n",
|
|
"## Prerequisites:\n",
|
|
"\n",
|
|
"Before running this notebook, run the `automl_setup` script described in README.md.\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Register Machine Learning Services Resource Provider\n",
|
|
"\n",
|
|
"Microsoft.MachineLearningServices only needs to be registed once in the subscription.\n",
|
|
"To register it:\n",
|
|
"1. Start the Azure portal.\n",
|
|
"2. Select your `All services` and then `Subscription`.\n",
|
|
"3. Select the subscription that you want to use.\n",
|
|
"4. Click on `Resource providers`\n",
|
|
"3. Click the `Register` link next to Microsoft.MachineLearningServices"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Check the Azure ML Core SDK Version to Validate Your Installation"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import azureml.core\n",
|
|
"\n",
|
|
"print(\"SDK Version:\", azureml.core.VERSION)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Initialize an Azure ML Workspace\n",
|
|
"### What is an Azure ML Workspace and Why Do I Need One?\n",
|
|
"\n",
|
|
"An Azure ML workspace is an Azure resource that organizes and coordinates the actions of many other Azure resources to assist in executing and sharing machine learning workflows. In particular, an Azure ML workspace coordinates storage, databases, and compute resources providing added functionality for machine learning experimentation, operationalization, and the monitoring of operationalized models.\n",
|
|
"\n",
|
|
"\n",
|
|
"### What do I Need?\n",
|
|
"\n",
|
|
"To create or access an Azure ML workspace, you will need to import the Azure ML library and specify following information:\n",
|
|
"* A name for your workspace. You can choose one.\n",
|
|
"* Your subscription id. Use the `id` value from the `az account show` command output above.\n",
|
|
"* The resource group name. The resource group organizes Azure resources and provides a default region for the resources in the group. The resource group will be created if it doesn't exist. Resource groups can be created and viewed in the [Azure portal](https://portal.azure.com)\n",
|
|
"* Supported regions include `eastus2`, `eastus`,`westcentralus`, `southeastasia`, `westeurope`, `australiaeast`, `westus2`, `southcentralus`."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"subscription_id = \"<subscription_id>\"\n",
|
|
"resource_group = \"myrg\"\n",
|
|
"workspace_name = \"myws\"\n",
|
|
"workspace_region = \"eastus2\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Creating a Workspace\n",
|
|
"If you already have access to an Azure ML workspace you want to use, you can skip this cell. Otherwise, this cell will create an Azure ML workspace for you in the specified subscription, provided you have the correct permissions for the given `subscription_id`.\n",
|
|
"\n",
|
|
"This will fail when:\n",
|
|
"1. The workspace already exists.\n",
|
|
"2. You do not have permission to create a workspace in the resource group.\n",
|
|
"3. You are not a subscription owner or contributor and no Azure ML workspaces have ever been created in this subscription.\n",
|
|
"\n",
|
|
"If workspace creation fails for any reason other than already existing, please work with your IT administrator to provide you with the appropriate permissions or to provision the required resources.\n",
|
|
"\n",
|
|
"**Note:** Creation of a new workspace can take several minutes."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Import the Workspace class and check the Azure ML SDK version.\n",
|
|
"from azureml.core import Workspace\n",
|
|
"\n",
|
|
"ws = Workspace.create(name = workspace_name,\n",
|
|
" subscription_id = subscription_id,\n",
|
|
" resource_group = resource_group, \n",
|
|
" location = workspace_region)\n",
|
|
"ws.get_details()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Configuring Your Local Environment\n",
|
|
"You can validate that you have access to the specified workspace and write a configuration file to the default configuration location, `./aml_config/config.json`."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from azureml.core import Workspace\n",
|
|
"\n",
|
|
"ws = Workspace(workspace_name = workspace_name,\n",
|
|
" subscription_id = subscription_id,\n",
|
|
" resource_group = resource_group)\n",
|
|
"\n",
|
|
"# Persist the subscription id, resource group name, and workspace name in aml_config/config.json.\n",
|
|
"ws.write_config()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"You can then load the workspace from this config file from any notebook in the current directory."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Load workspace configuration from ./aml_config/config.json file.\n",
|
|
"my_workspace = Workspace.from_config()\n",
|
|
"my_workspace.get_details()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Create a Folder to Host All Sample Projects\n",
|
|
"Finally, create a folder where all the sample projects will be hosted."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os\n",
|
|
"\n",
|
|
"sample_projects_folder = './sample_projects'\n",
|
|
"\n",
|
|
"if not os.path.isdir(sample_projects_folder):\n",
|
|
" os.mkdir(sample_projects_folder)\n",
|
|
" \n",
|
|
"print('Sample projects will be created in {}.'.format(sample_projects_folder))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Success!\n",
|
|
"Great, you are ready to move on to the rest of the sample notebooks."
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"authors": [
|
|
{
|
|
"name": "savitam"
|
|
}
|
|
],
|
|
"kernelspec": {
|
|
"display_name": "Python 3.6",
|
|
"language": "python",
|
|
"name": "python36"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.6.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
} |