266 lines
8.2 KiB
Plaintext
266 lines
8.2 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 and initialize your notebook directory to easily use this workspace. 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": [
|
|
"### Connect to your Azure Subscription\n",
|
|
"\n",
|
|
"In order to use an AML Workspace, first you need access to an Azure Subscription. You can [create your own](https://azure.microsoft.com/en-us/free/) or get your existing subscription information from the [Azure portal](https://portal.azure.com).\n",
|
|
"\n",
|
|
"First login to azure and follow prompts to authenticate. Then check that your subscription is correct"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"!az login"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"!az account show"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"If you have multiple subscriptions and need to change the active one, you can use a command\n",
|
|
"```shell\n",
|
|
"az account set -s <subscription-id>\n",
|
|
"```"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Register Machine Learning Services Resource Provider\n",
|
|
"\n",
|
|
"This step is required to use the Azure ML services backing the SDK."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# register the new RP\n",
|
|
"!az provider register -n Microsoft.MachineLearningServices\n",
|
|
"\n",
|
|
"# check the registration status\n",
|
|
"!az provider show -n Microsoft.MachineLearningServices"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Check core SDK version number for validate your installation and for debugging purposes"
|
|
]
|
|
},
|
|
{
|
|
"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 AML Workspace is an Azure resource that organaizes and coordinates the actions of many other Azure resources to assist in executing and sharing machine learning workflows. In particular, an AML 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 AML library and specify following information:\n",
|
|
"* A name for your workspace. You can choose one.\n",
|
|
"* Your subscription id. Use *id* value from *az account show* output above. \n",
|
|
"* The resource group name. Resource group organizes Azure resources and provides default region for the resources in the group. You can either specify a new one, in which case it gets created for your Workspace, or use an existing one or create a new one from [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 AML Workspace you want to use, you can skip this cell. Otherwise, this cell will create an AML workspace for you in a 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 admin to provide you with the appropriate permissions or to provision the required resources.\n",
|
|
"\n",
|
|
"**Note** The workspace creation can take several minutes."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# import the Workspace class and check the azureml 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 configuratio 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",
|
|
"Lastly, 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": {
|
|
"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
|
|
}
|