{ "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": [ "# Automated Machine Learning\n", "_**Exploring Previous Runs**_\n", "\n", "## Contents\n", "1. [Introduction](#Introduction)\n", "1. [Setup](#Setup)\n", "1. [Explore](#Explore)\n", "1. [Download](#Download)\n", "1. [Register](#Register)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "In this example we present some examples on navigating previously executed runs. We also show how you can download a fitted model for any previous run.\n", "\n", "Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n", "\n", "In this notebook you will learn how to:\n", "1. List all experiments in a workspace.\n", "2. List all AutoML runs in an experiment.\n", "3. Get details for an AutoML run, including settings, run widget, and all metrics.\n", "4. Download a fitted pipeline for any iteration." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import logging\n", "import os\n", "import random\n", "import re\n", "\n", "from matplotlib import pyplot as plt\n", "from matplotlib.pyplot import imshow\n", "import numpy as np\n", "import pandas as pd\n", "from sklearn import datasets\n", "\n", "import azureml.core\n", "from azureml.core.experiment import Experiment\n", "from azureml.core.run import Run\n", "from azureml.core.workspace import Workspace\n", "from azureml.train.automl import AutoMLConfig\n", "from azureml.train.automl.run import AutoMLRun" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ws = Workspace.from_config()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Opt-in diagnostics for better experience, quality, and security of future releases." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from azureml.telemetry import set_diagnostics_collection\n", "set_diagnostics_collection(send_diagnostics = True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Explore" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### List Experiments" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "experiment_list = Experiment.list(workspace=ws)\n", "\n", "summary_df = pd.DataFrame(index = ['No of Runs'])\n", "for experiment in experiment_list:\n", " automl_runs = list(experiment.get_runs(type='automl'))\n", " summary_df[experiment.name] = [len(automl_runs)]\n", " \n", "pd.set_option('display.max_colwidth', -1)\n", "summary_df.T" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### List runs for an experiment\n", "Set `experiment_name` to any experiment name from the result of the Experiment.list cell to load the AutoML runs." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "experiment_name = 'automl-local-classification' # Replace this with any project name from previous cell.\n", "\n", "proj = ws.experiments[experiment_name]\n", "summary_df = pd.DataFrame(index = ['Type', 'Status', 'Primary Metric', 'Iterations', 'Compute', 'Name'])\n", "automl_runs = list(proj.get_runs(type='automl'))\n", "automl_runs_project = []\n", "for run in automl_runs:\n", " properties = run.get_properties()\n", " tags = run.get_tags()\n", " amlsettings = eval(properties['RawAMLSettingsString'])\n", " if 'iterations' in tags:\n", " iterations = tags['iterations']\n", " else:\n", " iterations = properties['num_iterations']\n", " summary_df[run.id] = [amlsettings['task_type'], run.get_details()['status'], properties['primary_metric'], iterations, properties['target'], amlsettings['name']]\n", " if run.get_details()['status'] == 'Completed':\n", " automl_runs_project.append(run.id)\n", " \n", "from IPython.display import HTML\n", "projname_html = HTML(\"