├── .gitattributes
├── .gitignore
├── Connected Car Demo
├── .ipynb_checkpoints
│ └── devintersection-aml-demo-checkpoint.ipynb
├── .library.json
├── README.md
├── aml_config
│ └── config.json
├── amlcompute-cluster.ipynb
├── automl-regression
│ ├── __pycache__
│ │ └── get_data.cpython-36.pyc
│ └── get_data.py
├── automl.log
├── devintersection-aml-demo.ipynb
├── model.pkl
├── myenv-1.0.2.yml
├── myenv.yml
├── score.py
└── telemetry.log
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows thumbnail cache files
2 | Thumbs.db
3 | ehthumbs.db
4 | ehthumbs_vista.db
5 |
6 | # Folder config file
7 | Desktop.ini
8 |
9 | # Recycle Bin used on file shares
10 | $RECYCLE.BIN/
11 |
12 | # Windows Installer files
13 | *.cab
14 | *.msi
15 | *.msm
16 | *.msp
17 |
18 | # Windows shortcuts
19 | *.lnk
20 |
21 | # =========================
22 | # Operating System Files
23 | # =========================
24 |
--------------------------------------------------------------------------------
/Connected Car Demo/.ipynb_checkpoints/devintersection-aml-demo-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "metadata": {
5 | "trusted": true
6 | },
7 | "cell_type": "code",
8 | "source": "# constants\nsubscription_id = '2a779d6f-0806-4359-a6e8-f1fd57bb5dd7' \nresource_group = 'devintersection-2018-aml-demo'\nworkspace_name = 'devintersection-workspace'\nexperiment_name = 'automl-regression'\nproject_folder = './automl-regression'\ndata_url = \"https://devintersection.blob.core.windows.net/data/simulated-data.csv\"\ncluster_name = \"cpucluster\"\naks_cluster_name = 'my-aks-cluster' \nresource_id = '/subscriptions/2a779d6f-0806-4359-a6e8-f1fd57bb5dd7/resourceGroups/devintersection-2018-aml-demo/providers/Microsoft.BatchAI/workspaces/devintersection-workspace/clusters/cpucluster1c848275bca'",
9 | "execution_count": 25,
10 | "outputs": []
11 | },
12 | {
13 | "metadata": {},
14 | "cell_type": "markdown",
15 | "source": "### Import required packages"
16 | },
17 | {
18 | "metadata": {
19 | "trusted": true
20 | },
21 | "cell_type": "code",
22 | "source": "import logging\nimport os\nimport random\nimport re\n\nfrom matplotlib import pyplot as plt\nfrom matplotlib.pyplot import imshow\nimport numpy as np\nimport pandas as pd\nfrom sklearn import datasets\n\nimport azureml.core\nfrom azureml.core.experiment import Experiment\nfrom azureml.core.workspace import Workspace\nfrom azureml.core.compute import AksCompute, ComputeTarget\nfrom azureml.core.webservice import Webservice, AksWebservice\nfrom azureml.core.image import Image\nfrom azureml.core.model import Model\n\nfrom azureml.train.automl import AutoMLConfig\nfrom azureml.train.automl.run import AutoMLRun\n",
23 | "execution_count": 26,
24 | "outputs": []
25 | },
26 | {
27 | "metadata": {},
28 | "cell_type": "markdown",
29 | "source": "### Connect to Azure Workspace"
30 | },
31 | {
32 | "metadata": {
33 | "trusted": true
34 | },
35 | "cell_type": "code",
36 | "source": "from azureml.core import Workspace\n\ntry:\n ws = Workspace(subscription_id = subscription_id, resource_group = resource_group, workspace_name = workspace_name)\n ws.write_config()\n print('Library configuration succeeded')\nexcept:\n print('Workspace not found')",
37 | "execution_count": 27,
38 | "outputs": [
39 | {
40 | "output_type": "stream",
41 | "text": "Wrote the config file config.json to: /home/nbuser/library/aml_config/config.json\nLibrary configuration succeeded\n",
42 | "name": "stdout"
43 | }
44 | ]
45 | },
46 | {
47 | "metadata": {},
48 | "cell_type": "markdown",
49 | "source": "### Create a Workspace Experiment"
50 | },
51 | {
52 | "metadata": {
53 | "trusted": true
54 | },
55 | "cell_type": "code",
56 | "source": "ws = Workspace.from_config()\n\nimport os\n\noutput = {}\noutput['SDK version'] = azureml.core.VERSION\noutput['Subscription ID'] = ws.subscription_id\noutput['Workspace'] = ws.name\noutput['Resource Group'] = ws.resource_group\noutput['Location'] = ws.location\noutput['Project Directory'] = project_folder\npd.set_option('display.max_colwidth', -1)\npd.DataFrame(data=output, index=['']).T\n\nexperiment = Experiment(ws, experiment_name)",
57 | "execution_count": 4,
58 | "outputs": [
59 | {
60 | "output_type": "stream",
61 | "text": "Found the config file in: /home/nbuser/library/aml_config/config.json\n",
62 | "name": "stdout"
63 | }
64 | ]
65 | },
66 | {
67 | "metadata": {},
68 | "cell_type": "markdown",
69 | "source": "### Opt-in to send Diagnostics"
70 | },
71 | {
72 | "metadata": {
73 | "trusted": true
74 | },
75 | "cell_type": "code",
76 | "source": "from azureml.telemetry import set_diagnostics_collection\nset_diagnostics_collection(send_diagnostics=True)",
77 | "execution_count": 40,
78 | "outputs": []
79 | },
80 | {
81 | "metadata": {},
82 | "cell_type": "markdown",
83 | "source": "### Let's review our data"
84 | },
85 | {
86 | "metadata": {
87 | "trusted": true
88 | },
89 | "cell_type": "code",
90 | "source": "data = pd.read_csv(data_url)\nprint(data)",
91 | "execution_count": 10,
92 | "outputs": [
93 | {
94 | "output_type": "stream",
95 | "text": " Survival_In_Days Suffered_Freeze_Event Sex Car_Is_Garaged State \\\n0 975 False Female False KS \n1 1690 False Male True AR \n2 926 False Female True DE \n3 1742 False Male True IL \n4 1427 False Female True NY \n5 2280 False Male False CO \n6 743 False Female True HI \n7 1118 False Male True KY \n8 1835 False Female True AZ \n9 1508 False Male False FL \n10 1494 False Female True IN \n11 1511 False Male True AK \n12 2469 False Female True CT \n13 1022 False Female True ID \n14 504 False Male True LA \n15 2979 False Female False CA \n16 1284 False Male True GA \n17 1820 False Female True KS \n18 1120 False Male True AL \n19 1202 False Female False DE \n20 1281 False Male True IL \n21 1634 False Female True NY \n22 1209 False Male True CO \n23 1696 False Female True HI \n24 910 False Male True KY \n25 1787 False Female False AR \n26 2816 False Male True FL \n27 1335 False Female True IN \n28 2949 True Male True AK \n29 1273 True Female False CT \n... ... ... ... ... .. \n9970 2222 False Male True AZ \n9971 1544 False Female True GA \n9972 1136 False Male True IN \n9973 1354 False Female True AL \n9974 1202 False Male True DE \n9975 1659 False Female True ID \n9976 347 False Male True NY \n9977 1632 False Female True CA \n9978 1359 False Male True HI \n9979 1419 False Male True KS \n9980 1226 False Female True AR \n9981 1411 False Male True FL \n9982 2076 False Female True IL \n9983 1929 False Male True AK \n9984 2102 False Female True CO \n9985 2364 False Male True IA \n9986 545 False Female True LA \n9987 1211 False Male True AZ \n9988 1520 False Female True GA \n9989 1081 False Male True IN \n9990 1130 False Female False AL \n9991 1441 False Male True CT \n9992 1198 False Female True ID \n9993 1949 False Male True NY \n9994 2739 False Female True CA \n9995 685 False Male True HI \n9996 1404 False Female True KS \n9997 1321 False Male True AR \n9998 853 False Female True DE \n9999 1707 False Male True IL \n\n Trip_Length_Mean Trip_Length_Sigma Trips_Per_Day_Mean \\\n0 19.881840 6.627281 4.331634 \n1 13.756750 4.585582 4.957897 \n2 15.703370 5.234455 4.168737 \n3 12.811200 4.270401 4.960423 \n4 13.960390 4.653462 4.336687 \n5 13.103990 4.367997 4.697100 \n6 13.980740 4.660247 4.339213 \n7 19.747390 6.582462 4.965477 \n8 14.521340 4.840447 4.725462 \n9 14.461920 4.820640 4.318250 \n10 19.368440 6.456147 4.344266 \n11 9.780681 3.260227 4.970530 \n12 14.491300 4.830433 4.346612 \n13 17.080850 5.693616 4.723056 \n14 17.537850 5.845949 4.599319 \n15 17.441950 5.813983 4.624975 \n16 23.894240 7.964747 4.601846 \n17 14.107800 4.702600 4.728109 \n18 20.943550 6.981184 4.403338 \n19 16.793240 5.597747 4.246125 \n20 14.219350 4.739785 4.606899 \n21 13.171070 4.390358 4.733163 \n22 14.003030 4.667676 4.774488 \n23 13.165600 4.388534 4.735689 \n24 21.831870 7.277291 4.611953 \n25 18.951680 6.317227 4.052850 \n26 12.033130 4.011043 4.614479 \n27 18.318310 6.106103 4.740743 \n28 11.439270 3.813091 4.581213 \n29 15.272400 5.090801 4.424001 \n... ... ... ... \n9970 16.507810 5.502605 4.426755 \n9971 19.442770 6.480923 4.417577 \n9972 19.022180 6.340728 4.760365 \n9973 19.689870 6.563291 4.555545 \n9974 19.268070 6.422692 4.431808 \n9975 19.863850 6.621284 4.038727 \n9976 12.484960 4.161653 4.434335 \n9977 15.336380 5.112125 4.560598 \n9978 13.112860 4.370954 4.567090 \n9979 15.953870 5.317955 4.813125 \n9980 19.267070 6.422356 4.189388 \n9981 13.555520 4.518505 4.845452 \n9982 12.739180 4.246395 4.688240 \n9983 9.192115 3.064038 4.818178 \n9984 14.898550 4.966183 4.194442 \n9985 16.126010 5.375337 4.466602 \n9986 17.680080 5.893361 4.196968 \n9987 15.606220 5.202075 4.823232 \n9988 20.769570 6.923189 4.494965 \n9989 20.521830 6.840611 4.825758 \n9990 21.925410 7.308470 4.202022 \n9991 13.812090 4.604032 4.273328 \n9992 20.959410 6.986471 4.116115 \n9993 11.832690 3.944231 4.830812 \n9994 17.145080 5.715028 4.207075 \n9995 13.838120 4.612707 4.644478 \n9996 18.771860 6.257288 4.209601 \n9997 17.160630 5.720211 4.835865 \n9998 14.176650 4.725551 4.672841 \n9999 11.848380 3.949458 4.838391 \n\n Trips_Per_Day_Sigma Battery_Rated_Cycles ... Unnamed: 63 \\\n0 1.082908 200 ... 5.885037 \n1 1.239474 275 ... 15.662570 \n2 1.042184 200 ... 13.626230 \n3 1.240106 275 ... 1.524954 \n4 1.084172 200 ... 24.019970 \n5 1.174275 250 ... 3.537396 \n6 1.084803 300 ... 19.982340 \n7 1.241369 250 ... 14.819600 \n8 1.181366 300 ... 5.750768 \n9 1.079563 250 ... 17.144310 \n10 1.086067 275 ... 2.715143 \n11 1.242632 200 ... 7.765366 \n12 1.086653 275 ... 11.186960 \n13 1.180764 200 ... 6.340610 \n14 1.149830 275 ... 21.934390 \n15 1.156244 300 ... 33.380470 \n16 1.150462 250 ... 24.582780 \n17 1.182027 300 ... 23.049340 \n18 1.100834 250 ... 28.595800 \n19 1.061531 300 ... 22.261900 \n20 1.151725 200 ... 1.688892 \n21 1.183291 275 ... 16.737500 \n22 1.193622 200 ... 10.311140 \n23 1.183922 275 ... 23.378780 \n24 1.152988 200 ... 25.851530 \n25 1.013213 250 ... 29.420530 \n26 1.153620 300 ... 29.624060 \n27 1.185186 250 ... 13.917120 \n28 1.145303 300 ... -8.791608 \n29 1.106000 250 ... -8.191654 \n... ... ... ... ... \n9970 1.106689 275 ... 11.780950 \n9971 1.104394 300 ... 23.084510 \n9972 1.190091 250 ... -0.494365 \n9973 1.138886 300 ... 21.048560 \n9974 1.107952 250 ... 22.092970 \n9975 1.009682 300 ... 25.445760 \n9976 1.108584 200 ... 10.678750 \n9977 1.140150 275 ... 26.670610 \n9978 1.141773 200 ... 17.671140 \n9979 1.203281 275 ... 12.733070 \n9980 1.047347 200 ... 21.303450 \n9981 1.211363 250 ... 26.675870 \n9982 1.172060 300 ... 2.918624 \n9983 1.204545 250 ... 10.521750 \n9984 1.048610 300 ... 20.591250 \n9985 1.116651 250 ... 1.750168 \n9986 1.049242 275 ... 7.834110 \n9987 1.205808 200 ... 8.887084 \n9988 1.123741 275 ... 9.369227 \n9989 1.206439 200 ... 27.118660 \n9990 1.050505 275 ... 8.381648 \n9991 1.068332 200 ... 7.941643 \n9992 1.029029 250 ... 8.051712 \n9993 1.207703 300 ... 24.301640 \n9994 1.051769 250 ... 4.699893 \n9995 1.161119 300 ... 25.715740 \n9996 1.052400 250 ... 2.422462 \n9997 1.208966 275 ... 9.856892 \n9998 1.168210 200 ... 20.257340 \n9999 1.209598 275 ... 0.671654 \n\n Unnamed: 64 Unnamed: 65 Unnamed: 66 Unnamed: 67 Unnamed: 68 \\\n0 9.248038 10.692080 7.427279 10.150130 8.003028 \n1 10.963670 9.971108 13.596420 14.967640 12.708640 \n2 3.357746 9.103324 9.847462 10.116290 12.253490 \n3 0.186779 -1.560339 -1.271709 -0.740049 0.748998 \n4 26.386830 19.236590 25.555880 28.019140 21.703330 \n5 -1.574339 0.072585 -1.308728 2.101524 -1.705874 \n6 27.303420 19.071040 25.332570 25.270410 25.293810 \n7 14.489230 6.696948 14.253960 6.186900 13.798740 \n8 8.207089 6.028390 12.980760 17.273250 4.150208 \n9 20.518050 19.465560 18.647970 21.054930 20.451920 \n10 5.803380 2.754098 3.482927 3.768443 2.958594 \n11 5.132809 8.376112 8.829418 11.302430 11.153650 \n12 12.950750 14.826320 15.519410 18.766370 15.997180 \n13 13.312180 6.277401 8.630107 9.334005 10.047660 \n14 30.523080 27.075490 31.053500 35.172030 30.803660 \n15 17.104190 23.156510 13.591380 20.049710 19.935290 \n16 29.729230 17.841410 30.986120 27.311730 26.487190 \n17 28.586980 21.856440 26.630190 26.904900 28.179590 \n18 27.332440 26.952470 29.580300 27.735140 31.560260 \n19 25.630240 27.975370 23.624200 25.140840 24.835380 \n20 -2.100275 2.107286 -0.322256 -1.531558 -1.319234 \n21 21.456120 15.780430 21.016870 17.787750 17.937010 \n22 18.171730 16.107530 7.561697 10.606160 14.112700 \n23 26.181060 19.818820 23.042910 23.592550 24.890360 \n24 29.577770 25.195750 27.654150 27.432610 29.754370 \n25 25.926960 24.700820 26.540430 28.030950 26.103310 \n26 26.611150 25.310910 30.858290 26.497980 31.285780 \n27 16.436110 18.131180 13.854210 16.735800 13.638560 \n28 -5.836524 -9.130587 -5.727074 -10.123830 -6.003524 \n29 -0.812836 -5.163846 0.609199 -4.125057 3.974680 \n... ... ... ... ... ... \n9970 24.429860 24.007500 24.844600 21.456750 25.721670 \n9971 23.628370 19.473450 24.561720 25.150890 23.663640 \n9972 -1.560974 2.004552 0.018373 6.353423 4.285133 \n9973 30.887980 26.151930 28.462880 26.813160 29.748900 \n9974 27.013050 20.734920 23.171080 15.340040 17.889250 \n9975 15.716320 20.954630 20.575390 28.320340 22.685860 \n9976 11.327720 11.799080 14.491150 7.698203 12.072690 \n9977 22.255700 20.001830 25.234050 17.378680 23.774640 \n9978 24.396270 24.355900 24.714190 18.615630 21.926190 \n9979 13.706550 9.268698 13.135300 5.316308 14.509220 \n9980 27.191780 28.771640 25.744910 28.534480 28.031230 \n9981 29.560390 25.163550 30.016610 22.303150 27.921450 \n9982 2.198399 0.704123 2.854478 2.916392 5.091821 \n9983 11.869440 10.247610 8.365642 11.338280 9.549132 \n9984 21.318950 15.042190 21.783320 15.465270 18.700000 \n9985 1.307406 -1.301015 0.276911 -1.061732 -2.830951 \n9986 9.613855 5.874987 13.315920 13.566170 13.485340 \n9987 14.287670 15.597150 15.025010 10.915540 9.926949 \n9988 13.589150 21.166680 18.627360 15.080610 11.945260 \n9989 18.590620 19.478750 23.573720 22.385720 27.026720 \n9990 3.338191 12.085270 7.107628 7.982734 6.202570 \n9991 10.635270 8.100802 12.027220 8.988856 10.611550 \n9992 5.728095 1.683998 3.690072 2.126089 2.291296 \n9993 20.027400 13.221080 22.419490 16.839770 22.188370 \n9994 9.874402 6.425199 10.201180 6.580848 6.318543 \n9995 27.524110 24.637640 26.616430 21.180460 28.054000 \n9996 1.332137 4.702459 3.832925 0.917094 0.416384 \n9997 9.925304 11.966340 13.050960 10.787590 14.171940 \n9998 21.384620 21.534810 22.673590 13.896450 19.476170 \n9999 0.900555 -1.588768 0.613389 -1.343587 -0.424136 \n\n Unnamed: 69 Unnamed: 70 Unnamed: 71 Unnamed: 72 \n0 10.194430 4.946735 15.924040 5.384751 \n1 11.082640 10.682000 13.588690 16.587450 \n2 6.071704 11.544530 8.491552 8.369632 \n3 -0.426652 -2.047843 -0.878538 -1.426675 \n4 22.132250 22.553160 24.793370 23.237010 \n5 0.945893 -4.465286 5.387393 -2.423851 \n6 22.894980 26.179040 24.141760 25.649870 \n7 5.888587 11.678540 21.925180 21.131550 \n8 20.267980 13.283900 8.278644 12.689220 \n9 24.506060 20.542750 18.255540 17.976720 \n10 17.595270 4.842158 3.671377 6.560454 \n11 6.497259 11.327670 13.885170 11.664110 \n12 10.264420 15.337360 9.746139 13.961860 \n13 5.383865 13.696430 12.695660 9.705031 \n14 28.840960 25.482630 30.509750 30.719780 \n15 24.747580 17.531060 13.236280 16.462910 \n16 26.837350 29.607930 20.093090 28.961170 \n17 17.812020 24.260640 31.779510 30.158050 \n18 29.089660 32.354310 29.005450 29.629880 \n19 29.363860 23.437190 20.840910 25.380480 \n20 -1.301221 0.147075 -0.824145 0.120136 \n21 12.507510 18.480400 16.372450 16.652930 \n22 20.474900 17.002250 18.529600 19.214960 \n23 22.089710 26.319900 21.988770 26.452040 \n24 24.591220 27.959880 25.959200 26.709680 \n25 25.837370 22.985570 31.508550 26.154550 \n26 24.460150 31.704520 26.616580 32.343320 \n27 19.081990 18.546690 13.658630 10.747900 \n28 -8.874816 -3.928165 -5.280857 -2.641249 \n29 -3.139983 6.150460 -3.544506 2.844727 \n... ... ... ... ... \n9970 23.791130 23.302000 29.484960 24.739180 \n9971 27.593540 26.310860 15.916020 26.247700 \n9972 7.207629 4.442607 4.465589 4.520531 \n9973 19.778680 30.134640 22.024580 30.364300 \n9974 23.519980 18.604230 15.011140 20.225170 \n9975 15.367940 21.653890 16.063480 22.955080 \n9976 7.888649 11.102580 11.114720 11.328490 \n9977 24.732220 20.415840 17.040770 14.038070 \n9978 16.520150 22.867000 21.093210 24.493310 \n9979 6.894900 10.692940 10.908180 10.711670 \n9980 18.297020 24.119040 21.327890 23.245490 \n9981 23.862930 21.475490 26.968250 29.246810 \n9982 3.080497 2.834416 0.688928 4.021421 \n9983 7.674562 8.202930 8.057804 9.834734 \n9984 15.752190 19.766010 14.339690 21.788700 \n9985 4.510829 1.297283 0.322477 0.016122 \n9986 6.679179 11.455950 10.749140 11.620850 \n9987 8.546911 12.540790 11.229100 12.160420 \n9988 11.204610 19.085470 12.437590 16.866260 \n9989 26.627410 24.075380 25.361300 24.903690 \n9990 6.421227 2.692146 4.849164 5.864838 \n9991 12.645450 12.920840 11.554500 12.092000 \n9992 8.256313 6.216291 0.853202 -0.153655 \n9993 19.427110 19.020780 16.917530 17.898890 \n9994 9.017892 7.700435 6.296381 9.631056 \n9995 26.181880 28.916750 26.700910 27.254340 \n9996 2.764471 1.907135 0.747194 3.688787 \n9997 13.369320 14.128530 8.566240 16.568240 \n9998 17.846970 20.891510 18.584930 23.489340 \n9999 -1.050260 -0.751811 -0.620238 -1.411967 \n\n[10000 rows x 73 columns]\n",
96 | "name": "stdout"
97 | }
98 | ]
99 | },
100 | {
101 | "metadata": {},
102 | "cell_type": "markdown",
103 | "source": "### Create get_data.py for remote compute"
104 | },
105 | {
106 | "metadata": {
107 | "trusted": true
108 | },
109 | "cell_type": "code",
110 | "source": "# create project folder\nif not os.path.exists(project_folder):\n os.makedirs(project_folder)",
111 | "execution_count": 41,
112 | "outputs": []
113 | },
114 | {
115 | "metadata": {
116 | "trusted": true
117 | },
118 | "cell_type": "code",
119 | "source": "%%writefile $project_folder/get_data.py\n\nimport pandas as pd\nimport numpy as np\n\ndef get_data():\n \n data = pd.read_csv(\"https://devintersection.blob.core.windows.net/data/simulated-data.csv\")\n \n X = data.iloc[:,4:72]\n Y = np.empty(data.shape[0], dtype=object)\n Y[:] = data.iloc[:,0].tolist()\n\n return { \"X\" : X, \"y\" : Y }",
120 | "execution_count": 42,
121 | "outputs": [
122 | {
123 | "output_type": "stream",
124 | "text": "Overwriting ./automl-regression/get_data.py\n",
125 | "name": "stdout"
126 | }
127 | ]
128 | },
129 | {
130 | "metadata": {},
131 | "cell_type": "markdown",
132 | "source": "### Create AML Compute Cluster"
133 | },
134 | {
135 | "metadata": {
136 | "trusted": true
137 | },
138 | "cell_type": "code",
139 | "source": "### Create AML CPU Compute Cluster\n\nfrom azureml.core.compute import ComputeTarget, AmlCompute\nfrom azureml.core.compute_target import ComputeTargetException\n\ntry:\n compute_target = ComputeTarget(workspace=ws, name=cluster_name)\n print('Found existing compute target.')\nexcept ComputeTargetException:\n print('Creating a new compute target...')\n compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D12_V2',\n max_nodes=4)\n\n # create the cluster\n compute_target = ComputeTarget.create(ws, cluster_name, compute_config)\n\n compute_target.wait_for_completion(show_output=True)\n\n# Use the 'status' property to get a detailed status for the current AmlCompute. \nprint(compute_target.status.serialize())",
140 | "execution_count": 14,
141 | "outputs": [
142 | {
143 | "output_type": "stream",
144 | "text": "Found existing compute target.\n{'allocationState': 'steady', 'allocationStateTransitionTime': '2018-12-04T18:13:30.463000+00:00', 'creationTime': '2018-12-04T18:13:10.187000+00:00', 'currentNodeCount': 0, 'errors': None, 'nodeStateCounts': {'idleNodeCount': 0, 'leavingNodeCount': 0, 'preparingNodeCount': 0, 'runningNodeCount': 0, 'unusableNodeCount': 0}, 'provisioningState': 'succeeded', 'provisioningStateTransitionTime': '2018-12-04T18:13:29.797000+00:00', 'scaleSettings': {'manual': None, 'autoScale': {'maximumNodeCount': 4, 'minimumNodeCount': 0, 'initialNodeCount': 0}}, 'vmPriority': 'dedicated', 'vmSize': 'STANDARD_D12_V2'}\n",
145 | "name": "stdout"
146 | }
147 | ]
148 | },
149 | {
150 | "metadata": {},
151 | "cell_type": "markdown",
152 | "source": "### Instantiate an Automated ML Config"
153 | },
154 | {
155 | "metadata": {
156 | "trusted": true
157 | },
158 | "cell_type": "code",
159 | "source": "automl_config = AutoMLConfig(task = 'regression',\n iterations = 100,\n iteration_timeout_minutes = 10, \n max_cores_per_iteration = 10,\n preprocess= True,\n primary_metric='r2_score',\n n_cross_validations = 5,\n debug_log = 'automl.log',\n verbosity = logging.INFO,\n data_script = project_folder + \"/get_data.py\",\n compute_target = compute_target,\n blacklist_models = \"\",\n path = project_folder)",
160 | "execution_count": 19,
161 | "outputs": []
162 | },
163 | {
164 | "metadata": {},
165 | "cell_type": "markdown",
166 | "source": "### Run our Experiment on AML Compute"
167 | },
168 | {
169 | "metadata": {
170 | "trusted": true
171 | },
172 | "cell_type": "code",
173 | "source": "remote_run = experiment.submit(automl_config, show_output=False)\nremote_run",
174 | "execution_count": 20,
175 | "outputs": [
176 | {
177 | "output_type": "execute_result",
178 | "execution_count": 20,
179 | "data": {
180 | "text/html": "
",
181 | "text/plain": "Run(Experiment: automl-regression,\nId: AutoML_99de1c5a-78e3-4f33-ac20-36e4b02eec20,\nType: automl,\nStatus: Preparing)"
182 | },
183 | "metadata": {}
184 | }
185 | ]
186 | },
187 | {
188 | "metadata": {},
189 | "cell_type": "markdown",
190 | "source": "### Display Workspace Experiments"
191 | },
192 | {
193 | "metadata": {
194 | "trusted": true
195 | },
196 | "cell_type": "code",
197 | "source": "ws = Workspace.from_config()\nexperiment_list = Experiment.list(workspace=ws)\n\nsummary_df = pd.DataFrame(index = ['No of Runs'])\npattern = re.compile('^AutoML_[^_]*$')\nfor experiment in experiment_list:\n all_runs = list(experiment.get_runs())\n automl_runs = []\n for run in all_runs:\n if(pattern.match(run.id)):\n automl_runs.append(run) \n summary_df[experiment.name] = [len(automl_runs)]\n \npd.set_option('display.max_colwidth', -1)\nsummary_df.T",
198 | "execution_count": 5,
199 | "outputs": [
200 | {
201 | "output_type": "stream",
202 | "text": "Found the config file in: /home/nbuser/library/aml_config/config.json\n",
203 | "name": "stdout"
204 | },
205 | {
206 | "output_type": "execute_result",
207 | "execution_count": 5,
208 | "data": {
209 | "text/html": "\n\n
\n \n \n | \n No of Runs | \n
\n \n \n \n automl-regression | \n 5 | \n
\n \n
\n
",
210 | "text/plain": " No of Runs\nautoml-regression 5 "
211 | },
212 | "metadata": {}
213 | }
214 | ]
215 | },
216 | {
217 | "metadata": {},
218 | "cell_type": "markdown",
219 | "source": "### Display Automated ML Runs for the Experiment"
220 | },
221 | {
222 | "metadata": {
223 | "trusted": true,
224 | "scrolled": true
225 | },
226 | "cell_type": "code",
227 | "source": "proj = ws.experiments[experiment_name]\nsummary_df = pd.DataFrame(index = ['Type', 'Status', 'Primary Metric', 'Iterations', 'Compute', 'Name'])\npattern = re.compile('^AutoML_[^_]*$')\nall_runs = list(proj.get_runs(properties={'azureml.runsource': 'automl'}))\nfor run in all_runs:\n if(pattern.match(run.id)):\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 \nfrom IPython.display import HTML\nprojname_html = HTML(\"{}
\".format(proj.name))\n\nfrom IPython.display import display\ndisplay(projname_html)\ndisplay(summary_df.T)",
228 | "execution_count": 6,
229 | "outputs": [
230 | {
231 | "output_type": "display_data",
232 | "data": {
233 | "text/html": "automl-regression
",
234 | "text/plain": ""
235 | },
236 | "metadata": {}
237 | },
238 | {
239 | "output_type": "display_data",
240 | "data": {
241 | "text/html": "\n\n
\n \n \n | \n Type | \n Status | \n Primary Metric | \n Iterations | \n Compute | \n Name | \n
\n \n \n \n AutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2 | \n regression | \n Completed | \n r2_score | \n 100 | \n d12-cluster | \n automl-regression | \n
\n \n AutoML_e73345b0-5094-4bbe-970b-06f4521da5dd | \n regression | \n Completed | \n r2_score | \n 10 | \n d12-cluster | \n automl-regression | \n
\n \n AutoML_1e6dd094-9885-4998-a2d0-0a598956ed65 | \n regression | \n Completed | \n r2_score | \n 10 | \n d12-cluster | \n automl-regression | \n
\n \n AutoML_3e948b39-bab0-4cd5-bb60-fb3bdcc79e7e | \n regression | \n Completed | \n r2_score | \n 10 | \n d12-cluster | \n automl-regression | \n
\n \n AutoML_3ce57e56-58bb-45ab-923a-aa10393a4837 | \n regression | \n NotStarted | \n r2_score | \n 10 | \n d12-cluster | \n automl-regression | \n
\n \n
\n
",
242 | "text/plain": " Type Status \\\nAutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2 regression Completed \nAutoML_e73345b0-5094-4bbe-970b-06f4521da5dd regression Completed \nAutoML_1e6dd094-9885-4998-a2d0-0a598956ed65 regression Completed \nAutoML_3e948b39-bab0-4cd5-bb60-fb3bdcc79e7e regression Completed \nAutoML_3ce57e56-58bb-45ab-923a-aa10393a4837 regression NotStarted \n\n Primary Metric Iterations \\\nAutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2 r2_score 100 \nAutoML_e73345b0-5094-4bbe-970b-06f4521da5dd r2_score 10 \nAutoML_1e6dd094-9885-4998-a2d0-0a598956ed65 r2_score 10 \nAutoML_3e948b39-bab0-4cd5-bb60-fb3bdcc79e7e r2_score 10 \nAutoML_3ce57e56-58bb-45ab-923a-aa10393a4837 r2_score 10 \n\n Compute Name \nAutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2 d12-cluster automl-regression \nAutoML_e73345b0-5094-4bbe-970b-06f4521da5dd d12-cluster automl-regression \nAutoML_1e6dd094-9885-4998-a2d0-0a598956ed65 d12-cluster automl-regression \nAutoML_3e948b39-bab0-4cd5-bb60-fb3bdcc79e7e d12-cluster automl-regression \nAutoML_3ce57e56-58bb-45ab-923a-aa10393a4837 d12-cluster automl-regression "
243 | },
244 | "metadata": {}
245 | }
246 | ]
247 | },
248 | {
249 | "metadata": {},
250 | "cell_type": "markdown",
251 | "source": "### Display Automated ML Run Details"
252 | },
253 | {
254 | "metadata": {
255 | "trusted": true
256 | },
257 | "cell_type": "code",
258 | "source": "run_id = 'AutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2' \n\nfrom azureml.widgets import RunDetails\n\nexperiment = Experiment(ws, experiment_name)\nml_run = AutoMLRun(experiment=experiment, run_id=run_id)\n\nRunDetails(ml_run).show() ",
259 | "execution_count": 15,
260 | "outputs": [
261 | {
262 | "output_type": "display_data",
263 | "data": {
264 | "application/vnd.jupyter.widget-view+json": {
265 | "model_id": "b6746b6eb6c64c3895e171d40efe55d3",
266 | "version_minor": 0,
267 | "version_major": 2
268 | },
269 | "text/plain": "_AutoMLWidget(widget_settings={'childWidgetDisplay': 'popup', 'send_telemetry': False, 'log_level': 'NOTSET', …"
270 | },
271 | "metadata": {}
272 | }
273 | ]
274 | },
275 | {
276 | "metadata": {},
277 | "cell_type": "markdown",
278 | "source": "### Show best run and model"
279 | },
280 | {
281 | "metadata": {
282 | "trusted": true,
283 | "scrolled": true
284 | },
285 | "cell_type": "code",
286 | "source": "best_run, fitted_model = ml_run.get_output()\nprint(best_run)\nprint(fitted_model)",
287 | "execution_count": null,
288 | "outputs": []
289 | },
290 | {
291 | "metadata": {
292 | "trusted": true
293 | },
294 | "cell_type": "code",
295 | "source": "# show run and model from metric\nlookup_metric = \"root_mean_squared_error\"\nbest_run, fitted_model = ml_run.get_output(metric = lookup_metric)\nprint(best_run)\nprint(fitted_model)",
296 | "execution_count": null,
297 | "outputs": []
298 | },
299 | {
300 | "metadata": {
301 | "trusted": true
302 | },
303 | "cell_type": "code",
304 | "source": "# show run and model from iteration 3\niteration = 3\nthird_run, third_model = ml_run.get_output(iteration=iteration)\nprint(third_run)\nprint(third_model)",
305 | "execution_count": null,
306 | "outputs": []
307 | },
308 | {
309 | "metadata": {},
310 | "cell_type": "markdown",
311 | "source": "### Deploy the Model to AKS"
312 | },
313 | {
314 | "metadata": {
315 | "trusted": true
316 | },
317 | "cell_type": "code",
318 | "source": "# register the model for deployment\nmodel = Model.register(model_path = \"model.pkl\",\n model_name = \"model.pkl\",\n tags = {'area': \"auto\", 'type': \"regression\"},\n description = \"Contoso Auto model to predict battery failure\",\n workspace = ws)\n\nprint(model.name, model.description, model.version)",
319 | "execution_count": 49,
320 | "outputs": [
321 | {
322 | "output_type": "stream",
323 | "text": "Registering model model.pkl\nmodel.pkl Contoso Auto model to predict battery failure 4\n",
324 | "name": "stdout"
325 | }
326 | ]
327 | },
328 | {
329 | "metadata": {},
330 | "cell_type": "markdown",
331 | "source": "### Create Scoring File"
332 | },
333 | {
334 | "metadata": {
335 | "trusted": true
336 | },
337 | "cell_type": "code",
338 | "source": "%%writefile score.py\nimport pickle\nimport json\nimport numpy\nimport azureml.train.automl\nfrom sklearn.externals import joblib\nfrom azureml.core.model import Model\n\ndef init():\n global model\n model_path = Model.get_model_path('model.pkl') # this name is model.id of model that we want to deploy\n # deserialize the model file back into a sklearn model\n model = joblib.load(model_path)\n\ndef run(rawdata):\n try:\n data = json.loads(rawdata)['data']\n data = numpy.array(data)\n result = model.predict(data)\n except Exception as e:\n result = str(e)\n return json.dumps({\"error\": result})\n return json.dumps({\"result\":result.tolist()})",
339 | "execution_count": 79,
340 | "outputs": [
341 | {
342 | "output_type": "stream",
343 | "text": "Overwriting score.py\n",
344 | "name": "stdout"
345 | }
346 | ]
347 | },
348 | {
349 | "metadata": {},
350 | "cell_type": "markdown",
351 | "source": "### Create Environment Dependency File"
352 | },
353 | {
354 | "metadata": {
355 | "trusted": true
356 | },
357 | "cell_type": "code",
358 | "source": "from azureml.core.conda_dependencies import CondaDependencies \n\nmyenv = CondaDependencies.create(conda_packages=['numpy','scikit-learn'],pip_packages=['azureml-sdk[notebooks,automl]'])\nprint(myenv.serialize_to_string())\n\nwith open(\"myenv.yml\",\"w\") as f:\n f.write(myenv.serialize_to_string())",
359 | "execution_count": 59,
360 | "outputs": [
361 | {
362 | "output_type": "stream",
363 | "text": "# Conda environment specification. The dependencies defined in this file will\r\n# be automatically provisioned for runs with userManagedDependencies=False.\r\n\n# Details about the Conda environment file format:\r\n# https://conda.io/docs/user-guide/tasks/manage-environments.html#create-env-file-manually\r\n\nname: project_environment\ndependencies:\n # The python interpreter version.\r\n # Currently Azure ML only supports 3.5.2 and later.\r\n- python=3.6.2\n\n- pip:\n - azureml-sdk[notebooks,automl]==0.1.80\n- numpy\n- scikit-learn\n\n",
364 | "name": "stdout"
365 | }
366 | ]
367 | },
368 | {
369 | "metadata": {},
370 | "cell_type": "markdown",
371 | "source": "### Create Container Image"
372 | },
373 | {
374 | "metadata": {
375 | "trusted": true
376 | },
377 | "cell_type": "code",
378 | "source": "from azureml.core.image import ContainerImage\n\nimage_config = ContainerImage.image_configuration(execution_script = \"score.py\",\n runtime = \"python\",\n conda_file = \"myenv.yml\",\n description = \"Image with regression model\",\n tags = {'area': \"auto\", 'type': \"regression\"}\n )\n\nimage = ContainerImage.create(name = \"myimage1\",\n # this is the model object\n models = [model],\n image_config = image_config,\n workspace = ws)\n\nimage.wait_for_creation(show_output = True)",
379 | "execution_count": 80,
380 | "outputs": [
381 | {
382 | "output_type": "stream",
383 | "text": "Creating image\nRunning..................................................\nSucceededImage creation operation finished for image myimage1:11, operation \"Succeeded\"\n",
384 | "name": "stdout"
385 | }
386 | ]
387 | },
388 | {
389 | "metadata": {
390 | "trusted": true
391 | },
392 | "cell_type": "code",
393 | "source": "print(model.name, model.description, model.version)",
394 | "execution_count": 61,
395 | "outputs": [
396 | {
397 | "output_type": "stream",
398 | "text": "model.pkl Contoso Auto model to predict battery failure 4\n",
399 | "name": "stdout"
400 | }
401 | ]
402 | },
403 | {
404 | "metadata": {},
405 | "cell_type": "markdown",
406 | "source": "### Create AKS Compute Cluster"
407 | },
408 | {
409 | "metadata": {
410 | "trusted": true
411 | },
412 | "cell_type": "code",
413 | "source": "try:\n # attach to existing cluster\n aks_target = AksCompute.attach_configuration(resource_group,aks_cluster_name)\n print('Found existing compute target.')\n\nexcept ComputeTargetException:\n print('Creating a new compute target...')\n \n # Use the default configuration (can also provide parameters to customize)\n prov_config = AksCompute.provisioning_configuration()\n \n # Create the cluster\n aks_target = ComputeTarget.create(workspace = ws, \n name = aks_cluster_name, \n provisioning_configuration = prov_config)\n \n aks_target.wait_for_completion(True)",
414 | "execution_count": 18,
415 | "outputs": [
416 | {
417 | "output_type": "stream",
418 | "text": "Found existing compute target.\n",
419 | "name": "stdout"
420 | }
421 | ]
422 | },
423 | {
424 | "metadata": {
425 | "trusted": true
426 | },
427 | "cell_type": "code",
428 | "source": "%%time\naks_target.wait_for_completion(show_output = True)\nprint(aks_target.provisioning_state)\nprint(aks_target.provisioning_errors)",
429 | "execution_count": 63,
430 | "outputs": [
431 | {
432 | "output_type": "stream",
433 | "text": "SucceededProvisioning operation finished, operation \"Succeeded\"\nSucceeded\nNone\nCPU times: user 132 ms, sys: 19.2 ms, total: 151 ms\nWall time: 1.77 s\n",
434 | "name": "stdout"
435 | }
436 | ]
437 | },
438 | {
439 | "metadata": {},
440 | "cell_type": "markdown",
441 | "source": "### Activate Data Collection and App Insights"
442 | },
443 | {
444 | "metadata": {
445 | "trusted": true
446 | },
447 | "cell_type": "code",
448 | "source": "aks_config = AksWebservice.deploy_configuration(collect_model_data=True, enable_app_insights=True)",
449 | "execution_count": 34,
450 | "outputs": []
451 | },
452 | {
453 | "metadata": {},
454 | "cell_type": "markdown",
455 | "source": "### Deploy AKS Service"
456 | },
457 | {
458 | "metadata": {
459 | "trusted": true
460 | },
461 | "cell_type": "code",
462 | "source": "%%time\naks_service_name ='aks-automl-service'\n\naks_service = Webservice.deploy_from_image(workspace = ws, \n name = aks_service_name,\n image = image,\n deployment_config = aks_config,\n deployment_target = aks_target\n )\naks_service.wait_for_deployment(show_output = True)\nprint(aks_service.state)",
463 | "execution_count": 81,
464 | "outputs": [
465 | {
466 | "output_type": "stream",
467 | "text": "Creating service\nRunning..........\nSucceededAKS service creation operation finished, operation \"Succeeded\"\nHealthy\nCPU times: user 2.91 s, sys: 1.99 s, total: 4.91 s\nWall time: 1min 35s\n",
468 | "name": "stdout"
469 | }
470 | ]
471 | },
472 | {
473 | "metadata": {},
474 | "cell_type": "markdown",
475 | "source": "### Let's send some data to our deployed model for scoring"
476 | },
477 | {
478 | "metadata": {
479 | "trusted": true
480 | },
481 | "cell_type": "code",
482 | "source": "aks_service_name ='aml-deployment'\naks_service = Webservice(ws,aks_service_name)",
483 | "execution_count": 33,
484 | "outputs": []
485 | },
486 | {
487 | "metadata": {
488 | "trusted": true
489 | },
490 | "cell_type": "code",
491 | "source": "%%time\nimport json\n\ntest_sample = json.dumps({'data': [\n ['IL',11.84838,3.949458,4.838391,1.209598,275,'10/01/18 16:35',0.9831527,'TRUE',0.7995941,-8.11275,-0.4847943,0.4920518,-0.5428199,-2.321156,0.8585413,-0.3123408,0.7219636,1.097728,2.26926,-0.05967173,-0.5832617,0.8348302,-1.446835,-0.2638084,-0.7817461,-0.4884371,0.6024499,0.4706367,-0.8506926,0.3336521,-1.787212,-5.35282,-1.46283,-1.139778,-1.623536,0.9576696,-1.38004,-2.415984,-1.171993,1.130002,-0.8953804,0.7990591,-0.8824322,0.650575,0.01930443,0.2998053,-0.02662569,-2.049862,-1.750986,0.9513005,-1.56352,-4.504795,-1.260962,0.6667178,-1.560586,1.16729,1.19256,-0.7794458,0.671654,0.9005552,-1.588768,0.6133893,-1.343587,-0.4241357,-1.05026,-0.7518107,-0.6202381,-1.411967],\n ['DE',14.17665,4.725551,4.672841,1.16821,200,'30/09/04 9:55',0.8730668,'TRUE',18.80838,24.92621,19.49836,24.74844,17.68516,22.93362,25.37442,26.52723,23.5315,24.68806,26.10528,26.17741,23.21661,26.121,25.84424,27.08594,22.64841,24.81732,19.15317,24.85756,23.57444,23.50925,22.27799,26.55124,21.67293,25.02146,26.4417,27.2171,23.92386,22.08664,20.96359,25.51439,22.23584,27.07054,14.85068,20.55521,17.95652,24.07309,18.34271,24.09618,16.89754,22.32475,19.02732,18.38464,16.03233,20.88918,23.68929,24.01699,20.38528,18.55932,20.25734,21.38462,21.53481,22.67359,13.89645,19.47617,17.84697,20.89151,18.58493,23.48934]\n]})\ntest_sample = bytes(test_sample,encoding = 'utf8')\n\nprediction = aks_service.run(input_data = test_sample)\nprint(prediction)",
492 | "execution_count": 35,
493 | "outputs": [
494 | {
495 | "output_type": "stream",
496 | "text": "{\"result\": [1713.0575009811266, 1187.30301976508]}\nCPU times: user 756 ms, sys: 989 ms, total: 1.75 s\nWall time: 1.42 s\n",
497 | "name": "stdout"
498 | }
499 | ]
500 | },
501 | {
502 | "metadata": {
503 | "trusted": true
504 | },
505 | "cell_type": "code",
506 | "source": "",
507 | "execution_count": null,
508 | "outputs": []
509 | }
510 | ],
511 | "metadata": {
512 | "kernelspec": {
513 | "name": "python36",
514 | "display_name": "Python 3.6",
515 | "language": "python"
516 | },
517 | "language_info": {
518 | "mimetype": "text/x-python",
519 | "nbconvert_exporter": "python",
520 | "name": "python",
521 | "pygments_lexer": "ipython3",
522 | "version": "3.6.6",
523 | "file_extension": ".py",
524 | "codemirror_mode": {
525 | "version": 3,
526 | "name": "ipython"
527 | }
528 | }
529 | },
530 | "nbformat": 4,
531 | "nbformat_minor": 2
532 | }
--------------------------------------------------------------------------------
/Connected Car Demo/.library.json:
--------------------------------------------------------------------------------
1 | {"name":"AML service - Connected Car Demo","id":"connected-car","created":"12/6/2018 12:42:23 AM +00:00","modified":"12/6/2018 12:42:23 AM +00:00","lastBackedUp":"","accessed":"12/6/2018 12:42:23 AM +00:00","clonedFrom":"99bdf672a9944a63bc0333b369cd37eb","cloneCount":0,"gitRepositoryUrl":null,"public":"True","starCount":0,"setupSteps":[]}
--------------------------------------------------------------------------------
/Connected Car Demo/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nthacker/aml-demos/bff2ac2b18a4e6e13b139af54d15468076a7bb53/Connected Car Demo/README.md
--------------------------------------------------------------------------------
/Connected Car Demo/aml_config/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "subscription_id": "2a779d6f-0806-4359-a6e8-f1fd57bb5dd7",
3 | "resource_group": "devintersection-2018-aml-demo",
4 | "workspace_name": "devintersection-workspace"
5 | }
--------------------------------------------------------------------------------
/Connected Car Demo/amlcompute-cluster.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "metadata": {
5 | "collapsed": true,
6 | "trusted": false
7 | },
8 | "cell_type": "code",
9 | "source": "",
10 | "execution_count": null,
11 | "outputs": []
12 | },
13 | {
14 | "metadata": {
15 | "trusted": true
16 | },
17 | "cell_type": "code",
18 | "source": "from azureml.core import Workspace\n\nsubscription_id = '2a779d6f-0806-4359-a6e8-f1fd57bb5dd7' \nresource_group = 'devintersection-2018-aml-demo'\nworkspace_name = 'devintersection-workspace'\n\ntry:\n ws = Workspace(subscription_id = subscription_id, resource_group = resource_group, workspace_name = workspace_name)\n ws.write_config()\n print('Library configuration succeeded')\nexcept:\n print('Workspace not found')",
19 | "execution_count": 1,
20 | "outputs": [
21 | {
22 | "output_type": "stream",
23 | "text": "Wrote the config file config.json to: /home/nbuser/library/aml_config/config.json\nLibrary configuration succeeded\n",
24 | "name": "stdout"
25 | }
26 | ]
27 | },
28 | {
29 | "metadata": {
30 | "trusted": true
31 | },
32 | "cell_type": "code",
33 | "source": "from azureml.core.compute import ComputeTarget, AmlCompute\nfrom azureml.core.compute_target import ComputeTargetException\n\n# choose a name for your cluster\ncluster_name = \"cpucluster\"\n\ntry:\n compute_target = ComputeTarget(workspace=ws, name=cluster_name)\n print('Found existing compute target.')\nexcept ComputeTargetException:\n print('Creating a new compute target...')\n compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D12_V2',\n max_nodes=4)\n\n # create the cluster\n compute_target = ComputeTarget.create(ws, cluster_name, compute_config)\n\n compute_target.wait_for_completion(show_output=True)\n\n# Use the 'status' property to get a detailed status for the current AmlCompute. \nprint(compute_target.status.serialize())",
34 | "execution_count": 2,
35 | "outputs": [
36 | {
37 | "output_type": "stream",
38 | "text": "Creating a new compute target...\nCreating.\nAmlCompute wait for completion finished\nMinimum number of nodes requested have been provisioned\n{'allocationState': 'steady', 'allocationStateTransitionTime': '2018-12-04T18:13:30.463000+00:00', 'creationTime': '2018-12-04T18:13:10.187000+00:00', 'currentNodeCount': 0, 'errors': None, 'nodeStateCounts': {'idleNodeCount': 0, 'leavingNodeCount': 0, 'preparingNodeCount': 0, 'runningNodeCount': 0, 'unusableNodeCount': 0}, 'provisioningState': 'succeeded', 'provisioningStateTransitionTime': '2018-12-04T18:13:29.797000+00:00', 'scaleSettings': {'manual': None, 'autoScale': {'maximumNodeCount': 4, 'minimumNodeCount': 0, 'initialNodeCount': 0}}, 'vmPriority': 'dedicated', 'vmSize': 'STANDARD_D12_V2'}\n",
39 | "name": "stdout"
40 | }
41 | ]
42 | },
43 | {
44 | "metadata": {
45 | "trusted": true
46 | },
47 | "cell_type": "code",
48 | "source": "aks_cluster_name = 'my-aks-cluster' \nresource_id = '/subscriptions/2a779d6f-0806-4359-a6e8-f1fd57bb5dd7/resourceGroups/devintersection-2018-aml-demo/providers/Microsoft.BatchAI/workspaces/devintersection-workspace/clusters/cpucluster1c848275bca'\n\n",
49 | "execution_count": 3,
50 | "outputs": []
51 | },
52 | {
53 | "metadata": {
54 | "trusted": true
55 | },
56 | "cell_type": "code",
57 | "source": "from azureml.core.compute import AksCompute, ComputeTarget\n\ntry:\n # attach to existing cluster\n #aks_target = AksCompute.attach(workspace=ws, name=aks_cluster_name, resource_id=resource_id)\n \n aks_target = AksCompute.attach_configuration(resource_group,aks_cluster_name)\n \n print('Found existing compute target.')\nexcept ComputeTargetException:\n print('Creating a new compute target...')\n \n # Use the default configuration (can also provide parameters to customize)\n prov_config = AksCompute.provisioning_configuration()\n \n # Create the cluster\n aks_target = ComputeTarget.create(workspace = ws, \n name = aks_cluster_name, \n provisioning_configuration = prov_config)\n \n aks_target.wait_for_completion(True)",
58 | "execution_count": 6,
59 | "outputs": [
60 | {
61 | "output_type": "stream",
62 | "text": "Found existing compute target.\n",
63 | "name": "stdout"
64 | }
65 | ]
66 | },
67 | {
68 | "metadata": {
69 | "trusted": true
70 | },
71 | "cell_type": "code",
72 | "source": "import os\nprint(os.getcwd())",
73 | "execution_count": 8,
74 | "outputs": [
75 | {
76 | "output_type": "stream",
77 | "text": "/home/nbuser/library\n",
78 | "name": "stdout"
79 | }
80 | ]
81 | },
82 | {
83 | "metadata": {
84 | "trusted": true
85 | },
86 | "cell_type": "code",
87 | "source": "",
88 | "execution_count": null,
89 | "outputs": []
90 | }
91 | ],
92 | "metadata": {
93 | "kernelspec": {
94 | "name": "python36",
95 | "display_name": "Python 3.6",
96 | "language": "python"
97 | },
98 | "language_info": {
99 | "mimetype": "text/x-python",
100 | "nbconvert_exporter": "python",
101 | "name": "python",
102 | "pygments_lexer": "ipython3",
103 | "version": "3.6.6",
104 | "file_extension": ".py",
105 | "codemirror_mode": {
106 | "version": 3,
107 | "name": "ipython"
108 | }
109 | }
110 | },
111 | "nbformat": 4,
112 | "nbformat_minor": 2
113 | }
--------------------------------------------------------------------------------
/Connected Car Demo/automl-regression/__pycache__/get_data.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nthacker/aml-demos/bff2ac2b18a4e6e13b139af54d15468076a7bb53/Connected Car Demo/automl-regression/__pycache__/get_data.cpython-36.pyc
--------------------------------------------------------------------------------
/Connected Car Demo/automl-regression/get_data.py:
--------------------------------------------------------------------------------
1 |
2 | import pandas as pd
3 | import numpy as np
4 |
5 | def get_data():
6 |
7 | data = pd.read_csv("https://devintersection.blob.core.windows.net/data/simulated-data.csv")
8 |
9 | X = data.iloc[:,4:72]
10 | Y = np.empty(data.shape[0], dtype=object)
11 | Y[:] = data.iloc[:,0].tolist()
12 |
13 | return { "X" : X, "y" : Y }
14 |
--------------------------------------------------------------------------------
/Connected Car Demo/devintersection-aml-demo.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "metadata": {
5 | "trusted": true
6 | },
7 | "cell_type": "code",
8 | "source": "# constants\nsubscription_id = '2a779d6f-0806-4359-a6e8-f1fd57bb5dd7' \nresource_group = 'devintersection-2018-aml-demo'\nworkspace_name = 'devintersection-workspace'\nexperiment_name = 'automl-regression'\nproject_folder = './automl-regression'\ndata_url = \"https://devintersection.blob.core.windows.net/data/simulated-data.csv\"\ncluster_name = \"cpucluster\"\naks_cluster_name = 'my-aks-cluster' \nresource_id = '/subscriptions/2a779d6f-0806-4359-a6e8-f1fd57bb5dd7/resourceGroups/devintersection-2018-aml-demo/providers/Microsoft.BatchAI/workspaces/devintersection-workspace/clusters/cpucluster1c848275bca'",
9 | "execution_count": 25,
10 | "outputs": []
11 | },
12 | {
13 | "metadata": {},
14 | "cell_type": "markdown",
15 | "source": "### Import required packages"
16 | },
17 | {
18 | "metadata": {
19 | "trusted": true
20 | },
21 | "cell_type": "code",
22 | "source": "import logging\nimport os\nimport random\nimport re\n\nfrom matplotlib import pyplot as plt\nfrom matplotlib.pyplot import imshow\nimport numpy as np\nimport pandas as pd\nfrom sklearn import datasets\n\nimport azureml.core\nfrom azureml.core.experiment import Experiment\nfrom azureml.core.workspace import Workspace\nfrom azureml.core.compute import AksCompute, ComputeTarget\nfrom azureml.core.webservice import Webservice, AksWebservice\nfrom azureml.core.image import Image\nfrom azureml.core.model import Model\n\nfrom azureml.train.automl import AutoMLConfig\nfrom azureml.train.automl.run import AutoMLRun\n",
23 | "execution_count": 26,
24 | "outputs": []
25 | },
26 | {
27 | "metadata": {},
28 | "cell_type": "markdown",
29 | "source": "### Connect to Azure Workspace"
30 | },
31 | {
32 | "metadata": {
33 | "trusted": true
34 | },
35 | "cell_type": "code",
36 | "source": "from azureml.core import Workspace\n\ntry:\n ws = Workspace(subscription_id = subscription_id, resource_group = resource_group, workspace_name = workspace_name)\n ws.write_config()\n print('Library configuration succeeded')\nexcept:\n print('Workspace not found')",
37 | "execution_count": 27,
38 | "outputs": [
39 | {
40 | "output_type": "stream",
41 | "text": "Wrote the config file config.json to: /home/nbuser/library/aml_config/config.json\nLibrary configuration succeeded\n",
42 | "name": "stdout"
43 | }
44 | ]
45 | },
46 | {
47 | "metadata": {},
48 | "cell_type": "markdown",
49 | "source": "### Create a Workspace Experiment"
50 | },
51 | {
52 | "metadata": {
53 | "trusted": true
54 | },
55 | "cell_type": "code",
56 | "source": "ws = Workspace.from_config()\n\nimport os\n\noutput = {}\noutput['SDK version'] = azureml.core.VERSION\noutput['Subscription ID'] = ws.subscription_id\noutput['Workspace'] = ws.name\noutput['Resource Group'] = ws.resource_group\noutput['Location'] = ws.location\noutput['Project Directory'] = project_folder\npd.set_option('display.max_colwidth', -1)\npd.DataFrame(data=output, index=['']).T\n\nexperiment = Experiment(ws, experiment_name)",
57 | "execution_count": 4,
58 | "outputs": [
59 | {
60 | "output_type": "stream",
61 | "text": "Found the config file in: /home/nbuser/library/aml_config/config.json\n",
62 | "name": "stdout"
63 | }
64 | ]
65 | },
66 | {
67 | "metadata": {},
68 | "cell_type": "markdown",
69 | "source": "### Opt-in to send Diagnostics"
70 | },
71 | {
72 | "metadata": {
73 | "trusted": true
74 | },
75 | "cell_type": "code",
76 | "source": "from azureml.telemetry import set_diagnostics_collection\nset_diagnostics_collection(send_diagnostics=True)",
77 | "execution_count": 40,
78 | "outputs": []
79 | },
80 | {
81 | "metadata": {},
82 | "cell_type": "markdown",
83 | "source": "### Let's review our data"
84 | },
85 | {
86 | "metadata": {
87 | "trusted": true
88 | },
89 | "cell_type": "code",
90 | "source": "data = pd.read_csv(data_url)\nprint(data)",
91 | "execution_count": 10,
92 | "outputs": [
93 | {
94 | "output_type": "stream",
95 | "text": " Survival_In_Days Suffered_Freeze_Event Sex Car_Is_Garaged State \\\n0 975 False Female False KS \n1 1690 False Male True AR \n2 926 False Female True DE \n3 1742 False Male True IL \n4 1427 False Female True NY \n5 2280 False Male False CO \n6 743 False Female True HI \n7 1118 False Male True KY \n8 1835 False Female True AZ \n9 1508 False Male False FL \n10 1494 False Female True IN \n11 1511 False Male True AK \n12 2469 False Female True CT \n13 1022 False Female True ID \n14 504 False Male True LA \n15 2979 False Female False CA \n16 1284 False Male True GA \n17 1820 False Female True KS \n18 1120 False Male True AL \n19 1202 False Female False DE \n20 1281 False Male True IL \n21 1634 False Female True NY \n22 1209 False Male True CO \n23 1696 False Female True HI \n24 910 False Male True KY \n25 1787 False Female False AR \n26 2816 False Male True FL \n27 1335 False Female True IN \n28 2949 True Male True AK \n29 1273 True Female False CT \n... ... ... ... ... .. \n9970 2222 False Male True AZ \n9971 1544 False Female True GA \n9972 1136 False Male True IN \n9973 1354 False Female True AL \n9974 1202 False Male True DE \n9975 1659 False Female True ID \n9976 347 False Male True NY \n9977 1632 False Female True CA \n9978 1359 False Male True HI \n9979 1419 False Male True KS \n9980 1226 False Female True AR \n9981 1411 False Male True FL \n9982 2076 False Female True IL \n9983 1929 False Male True AK \n9984 2102 False Female True CO \n9985 2364 False Male True IA \n9986 545 False Female True LA \n9987 1211 False Male True AZ \n9988 1520 False Female True GA \n9989 1081 False Male True IN \n9990 1130 False Female False AL \n9991 1441 False Male True CT \n9992 1198 False Female True ID \n9993 1949 False Male True NY \n9994 2739 False Female True CA \n9995 685 False Male True HI \n9996 1404 False Female True KS \n9997 1321 False Male True AR \n9998 853 False Female True DE \n9999 1707 False Male True IL \n\n Trip_Length_Mean Trip_Length_Sigma Trips_Per_Day_Mean \\\n0 19.881840 6.627281 4.331634 \n1 13.756750 4.585582 4.957897 \n2 15.703370 5.234455 4.168737 \n3 12.811200 4.270401 4.960423 \n4 13.960390 4.653462 4.336687 \n5 13.103990 4.367997 4.697100 \n6 13.980740 4.660247 4.339213 \n7 19.747390 6.582462 4.965477 \n8 14.521340 4.840447 4.725462 \n9 14.461920 4.820640 4.318250 \n10 19.368440 6.456147 4.344266 \n11 9.780681 3.260227 4.970530 \n12 14.491300 4.830433 4.346612 \n13 17.080850 5.693616 4.723056 \n14 17.537850 5.845949 4.599319 \n15 17.441950 5.813983 4.624975 \n16 23.894240 7.964747 4.601846 \n17 14.107800 4.702600 4.728109 \n18 20.943550 6.981184 4.403338 \n19 16.793240 5.597747 4.246125 \n20 14.219350 4.739785 4.606899 \n21 13.171070 4.390358 4.733163 \n22 14.003030 4.667676 4.774488 \n23 13.165600 4.388534 4.735689 \n24 21.831870 7.277291 4.611953 \n25 18.951680 6.317227 4.052850 \n26 12.033130 4.011043 4.614479 \n27 18.318310 6.106103 4.740743 \n28 11.439270 3.813091 4.581213 \n29 15.272400 5.090801 4.424001 \n... ... ... ... \n9970 16.507810 5.502605 4.426755 \n9971 19.442770 6.480923 4.417577 \n9972 19.022180 6.340728 4.760365 \n9973 19.689870 6.563291 4.555545 \n9974 19.268070 6.422692 4.431808 \n9975 19.863850 6.621284 4.038727 \n9976 12.484960 4.161653 4.434335 \n9977 15.336380 5.112125 4.560598 \n9978 13.112860 4.370954 4.567090 \n9979 15.953870 5.317955 4.813125 \n9980 19.267070 6.422356 4.189388 \n9981 13.555520 4.518505 4.845452 \n9982 12.739180 4.246395 4.688240 \n9983 9.192115 3.064038 4.818178 \n9984 14.898550 4.966183 4.194442 \n9985 16.126010 5.375337 4.466602 \n9986 17.680080 5.893361 4.196968 \n9987 15.606220 5.202075 4.823232 \n9988 20.769570 6.923189 4.494965 \n9989 20.521830 6.840611 4.825758 \n9990 21.925410 7.308470 4.202022 \n9991 13.812090 4.604032 4.273328 \n9992 20.959410 6.986471 4.116115 \n9993 11.832690 3.944231 4.830812 \n9994 17.145080 5.715028 4.207075 \n9995 13.838120 4.612707 4.644478 \n9996 18.771860 6.257288 4.209601 \n9997 17.160630 5.720211 4.835865 \n9998 14.176650 4.725551 4.672841 \n9999 11.848380 3.949458 4.838391 \n\n Trips_Per_Day_Sigma Battery_Rated_Cycles ... Unnamed: 63 \\\n0 1.082908 200 ... 5.885037 \n1 1.239474 275 ... 15.662570 \n2 1.042184 200 ... 13.626230 \n3 1.240106 275 ... 1.524954 \n4 1.084172 200 ... 24.019970 \n5 1.174275 250 ... 3.537396 \n6 1.084803 300 ... 19.982340 \n7 1.241369 250 ... 14.819600 \n8 1.181366 300 ... 5.750768 \n9 1.079563 250 ... 17.144310 \n10 1.086067 275 ... 2.715143 \n11 1.242632 200 ... 7.765366 \n12 1.086653 275 ... 11.186960 \n13 1.180764 200 ... 6.340610 \n14 1.149830 275 ... 21.934390 \n15 1.156244 300 ... 33.380470 \n16 1.150462 250 ... 24.582780 \n17 1.182027 300 ... 23.049340 \n18 1.100834 250 ... 28.595800 \n19 1.061531 300 ... 22.261900 \n20 1.151725 200 ... 1.688892 \n21 1.183291 275 ... 16.737500 \n22 1.193622 200 ... 10.311140 \n23 1.183922 275 ... 23.378780 \n24 1.152988 200 ... 25.851530 \n25 1.013213 250 ... 29.420530 \n26 1.153620 300 ... 29.624060 \n27 1.185186 250 ... 13.917120 \n28 1.145303 300 ... -8.791608 \n29 1.106000 250 ... -8.191654 \n... ... ... ... ... \n9970 1.106689 275 ... 11.780950 \n9971 1.104394 300 ... 23.084510 \n9972 1.190091 250 ... -0.494365 \n9973 1.138886 300 ... 21.048560 \n9974 1.107952 250 ... 22.092970 \n9975 1.009682 300 ... 25.445760 \n9976 1.108584 200 ... 10.678750 \n9977 1.140150 275 ... 26.670610 \n9978 1.141773 200 ... 17.671140 \n9979 1.203281 275 ... 12.733070 \n9980 1.047347 200 ... 21.303450 \n9981 1.211363 250 ... 26.675870 \n9982 1.172060 300 ... 2.918624 \n9983 1.204545 250 ... 10.521750 \n9984 1.048610 300 ... 20.591250 \n9985 1.116651 250 ... 1.750168 \n9986 1.049242 275 ... 7.834110 \n9987 1.205808 200 ... 8.887084 \n9988 1.123741 275 ... 9.369227 \n9989 1.206439 200 ... 27.118660 \n9990 1.050505 275 ... 8.381648 \n9991 1.068332 200 ... 7.941643 \n9992 1.029029 250 ... 8.051712 \n9993 1.207703 300 ... 24.301640 \n9994 1.051769 250 ... 4.699893 \n9995 1.161119 300 ... 25.715740 \n9996 1.052400 250 ... 2.422462 \n9997 1.208966 275 ... 9.856892 \n9998 1.168210 200 ... 20.257340 \n9999 1.209598 275 ... 0.671654 \n\n Unnamed: 64 Unnamed: 65 Unnamed: 66 Unnamed: 67 Unnamed: 68 \\\n0 9.248038 10.692080 7.427279 10.150130 8.003028 \n1 10.963670 9.971108 13.596420 14.967640 12.708640 \n2 3.357746 9.103324 9.847462 10.116290 12.253490 \n3 0.186779 -1.560339 -1.271709 -0.740049 0.748998 \n4 26.386830 19.236590 25.555880 28.019140 21.703330 \n5 -1.574339 0.072585 -1.308728 2.101524 -1.705874 \n6 27.303420 19.071040 25.332570 25.270410 25.293810 \n7 14.489230 6.696948 14.253960 6.186900 13.798740 \n8 8.207089 6.028390 12.980760 17.273250 4.150208 \n9 20.518050 19.465560 18.647970 21.054930 20.451920 \n10 5.803380 2.754098 3.482927 3.768443 2.958594 \n11 5.132809 8.376112 8.829418 11.302430 11.153650 \n12 12.950750 14.826320 15.519410 18.766370 15.997180 \n13 13.312180 6.277401 8.630107 9.334005 10.047660 \n14 30.523080 27.075490 31.053500 35.172030 30.803660 \n15 17.104190 23.156510 13.591380 20.049710 19.935290 \n16 29.729230 17.841410 30.986120 27.311730 26.487190 \n17 28.586980 21.856440 26.630190 26.904900 28.179590 \n18 27.332440 26.952470 29.580300 27.735140 31.560260 \n19 25.630240 27.975370 23.624200 25.140840 24.835380 \n20 -2.100275 2.107286 -0.322256 -1.531558 -1.319234 \n21 21.456120 15.780430 21.016870 17.787750 17.937010 \n22 18.171730 16.107530 7.561697 10.606160 14.112700 \n23 26.181060 19.818820 23.042910 23.592550 24.890360 \n24 29.577770 25.195750 27.654150 27.432610 29.754370 \n25 25.926960 24.700820 26.540430 28.030950 26.103310 \n26 26.611150 25.310910 30.858290 26.497980 31.285780 \n27 16.436110 18.131180 13.854210 16.735800 13.638560 \n28 -5.836524 -9.130587 -5.727074 -10.123830 -6.003524 \n29 -0.812836 -5.163846 0.609199 -4.125057 3.974680 \n... ... ... ... ... ... \n9970 24.429860 24.007500 24.844600 21.456750 25.721670 \n9971 23.628370 19.473450 24.561720 25.150890 23.663640 \n9972 -1.560974 2.004552 0.018373 6.353423 4.285133 \n9973 30.887980 26.151930 28.462880 26.813160 29.748900 \n9974 27.013050 20.734920 23.171080 15.340040 17.889250 \n9975 15.716320 20.954630 20.575390 28.320340 22.685860 \n9976 11.327720 11.799080 14.491150 7.698203 12.072690 \n9977 22.255700 20.001830 25.234050 17.378680 23.774640 \n9978 24.396270 24.355900 24.714190 18.615630 21.926190 \n9979 13.706550 9.268698 13.135300 5.316308 14.509220 \n9980 27.191780 28.771640 25.744910 28.534480 28.031230 \n9981 29.560390 25.163550 30.016610 22.303150 27.921450 \n9982 2.198399 0.704123 2.854478 2.916392 5.091821 \n9983 11.869440 10.247610 8.365642 11.338280 9.549132 \n9984 21.318950 15.042190 21.783320 15.465270 18.700000 \n9985 1.307406 -1.301015 0.276911 -1.061732 -2.830951 \n9986 9.613855 5.874987 13.315920 13.566170 13.485340 \n9987 14.287670 15.597150 15.025010 10.915540 9.926949 \n9988 13.589150 21.166680 18.627360 15.080610 11.945260 \n9989 18.590620 19.478750 23.573720 22.385720 27.026720 \n9990 3.338191 12.085270 7.107628 7.982734 6.202570 \n9991 10.635270 8.100802 12.027220 8.988856 10.611550 \n9992 5.728095 1.683998 3.690072 2.126089 2.291296 \n9993 20.027400 13.221080 22.419490 16.839770 22.188370 \n9994 9.874402 6.425199 10.201180 6.580848 6.318543 \n9995 27.524110 24.637640 26.616430 21.180460 28.054000 \n9996 1.332137 4.702459 3.832925 0.917094 0.416384 \n9997 9.925304 11.966340 13.050960 10.787590 14.171940 \n9998 21.384620 21.534810 22.673590 13.896450 19.476170 \n9999 0.900555 -1.588768 0.613389 -1.343587 -0.424136 \n\n Unnamed: 69 Unnamed: 70 Unnamed: 71 Unnamed: 72 \n0 10.194430 4.946735 15.924040 5.384751 \n1 11.082640 10.682000 13.588690 16.587450 \n2 6.071704 11.544530 8.491552 8.369632 \n3 -0.426652 -2.047843 -0.878538 -1.426675 \n4 22.132250 22.553160 24.793370 23.237010 \n5 0.945893 -4.465286 5.387393 -2.423851 \n6 22.894980 26.179040 24.141760 25.649870 \n7 5.888587 11.678540 21.925180 21.131550 \n8 20.267980 13.283900 8.278644 12.689220 \n9 24.506060 20.542750 18.255540 17.976720 \n10 17.595270 4.842158 3.671377 6.560454 \n11 6.497259 11.327670 13.885170 11.664110 \n12 10.264420 15.337360 9.746139 13.961860 \n13 5.383865 13.696430 12.695660 9.705031 \n14 28.840960 25.482630 30.509750 30.719780 \n15 24.747580 17.531060 13.236280 16.462910 \n16 26.837350 29.607930 20.093090 28.961170 \n17 17.812020 24.260640 31.779510 30.158050 \n18 29.089660 32.354310 29.005450 29.629880 \n19 29.363860 23.437190 20.840910 25.380480 \n20 -1.301221 0.147075 -0.824145 0.120136 \n21 12.507510 18.480400 16.372450 16.652930 \n22 20.474900 17.002250 18.529600 19.214960 \n23 22.089710 26.319900 21.988770 26.452040 \n24 24.591220 27.959880 25.959200 26.709680 \n25 25.837370 22.985570 31.508550 26.154550 \n26 24.460150 31.704520 26.616580 32.343320 \n27 19.081990 18.546690 13.658630 10.747900 \n28 -8.874816 -3.928165 -5.280857 -2.641249 \n29 -3.139983 6.150460 -3.544506 2.844727 \n... ... ... ... ... \n9970 23.791130 23.302000 29.484960 24.739180 \n9971 27.593540 26.310860 15.916020 26.247700 \n9972 7.207629 4.442607 4.465589 4.520531 \n9973 19.778680 30.134640 22.024580 30.364300 \n9974 23.519980 18.604230 15.011140 20.225170 \n9975 15.367940 21.653890 16.063480 22.955080 \n9976 7.888649 11.102580 11.114720 11.328490 \n9977 24.732220 20.415840 17.040770 14.038070 \n9978 16.520150 22.867000 21.093210 24.493310 \n9979 6.894900 10.692940 10.908180 10.711670 \n9980 18.297020 24.119040 21.327890 23.245490 \n9981 23.862930 21.475490 26.968250 29.246810 \n9982 3.080497 2.834416 0.688928 4.021421 \n9983 7.674562 8.202930 8.057804 9.834734 \n9984 15.752190 19.766010 14.339690 21.788700 \n9985 4.510829 1.297283 0.322477 0.016122 \n9986 6.679179 11.455950 10.749140 11.620850 \n9987 8.546911 12.540790 11.229100 12.160420 \n9988 11.204610 19.085470 12.437590 16.866260 \n9989 26.627410 24.075380 25.361300 24.903690 \n9990 6.421227 2.692146 4.849164 5.864838 \n9991 12.645450 12.920840 11.554500 12.092000 \n9992 8.256313 6.216291 0.853202 -0.153655 \n9993 19.427110 19.020780 16.917530 17.898890 \n9994 9.017892 7.700435 6.296381 9.631056 \n9995 26.181880 28.916750 26.700910 27.254340 \n9996 2.764471 1.907135 0.747194 3.688787 \n9997 13.369320 14.128530 8.566240 16.568240 \n9998 17.846970 20.891510 18.584930 23.489340 \n9999 -1.050260 -0.751811 -0.620238 -1.411967 \n\n[10000 rows x 73 columns]\n",
96 | "name": "stdout"
97 | }
98 | ]
99 | },
100 | {
101 | "metadata": {},
102 | "cell_type": "markdown",
103 | "source": "### Create get_data.py for remote compute"
104 | },
105 | {
106 | "metadata": {
107 | "trusted": true
108 | },
109 | "cell_type": "code",
110 | "source": "# create project folder\nif not os.path.exists(project_folder):\n os.makedirs(project_folder)",
111 | "execution_count": 41,
112 | "outputs": []
113 | },
114 | {
115 | "metadata": {
116 | "trusted": true
117 | },
118 | "cell_type": "code",
119 | "source": "%%writefile $project_folder/get_data.py\n\nimport pandas as pd\nimport numpy as np\n\ndef get_data():\n \n data = pd.read_csv(\"https://devintersection.blob.core.windows.net/data/simulated-data.csv\")\n \n X = data.iloc[:,4:72]\n Y = np.empty(data.shape[0], dtype=object)\n Y[:] = data.iloc[:,0].tolist()\n\n return { \"X\" : X, \"y\" : Y }",
120 | "execution_count": 42,
121 | "outputs": [
122 | {
123 | "output_type": "stream",
124 | "text": "Overwriting ./automl-regression/get_data.py\n",
125 | "name": "stdout"
126 | }
127 | ]
128 | },
129 | {
130 | "metadata": {},
131 | "cell_type": "markdown",
132 | "source": "### Create AML Compute Cluster"
133 | },
134 | {
135 | "metadata": {
136 | "trusted": true
137 | },
138 | "cell_type": "code",
139 | "source": "### Create AML CPU Compute Cluster\n\nfrom azureml.core.compute import ComputeTarget, AmlCompute\nfrom azureml.core.compute_target import ComputeTargetException\n\ntry:\n compute_target = ComputeTarget(workspace=ws, name=cluster_name)\n print('Found existing compute target.')\nexcept ComputeTargetException:\n print('Creating a new compute target...')\n compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D12_V2',\n max_nodes=4)\n\n # create the cluster\n compute_target = ComputeTarget.create(ws, cluster_name, compute_config)\n\n compute_target.wait_for_completion(show_output=True)\n\n# Use the 'status' property to get a detailed status for the current AmlCompute. \nprint(compute_target.status.serialize())",
140 | "execution_count": 14,
141 | "outputs": [
142 | {
143 | "output_type": "stream",
144 | "text": "Found existing compute target.\n{'allocationState': 'steady', 'allocationStateTransitionTime': '2018-12-04T18:13:30.463000+00:00', 'creationTime': '2018-12-04T18:13:10.187000+00:00', 'currentNodeCount': 0, 'errors': None, 'nodeStateCounts': {'idleNodeCount': 0, 'leavingNodeCount': 0, 'preparingNodeCount': 0, 'runningNodeCount': 0, 'unusableNodeCount': 0}, 'provisioningState': 'succeeded', 'provisioningStateTransitionTime': '2018-12-04T18:13:29.797000+00:00', 'scaleSettings': {'manual': None, 'autoScale': {'maximumNodeCount': 4, 'minimumNodeCount': 0, 'initialNodeCount': 0}}, 'vmPriority': 'dedicated', 'vmSize': 'STANDARD_D12_V2'}\n",
145 | "name": "stdout"
146 | }
147 | ]
148 | },
149 | {
150 | "metadata": {},
151 | "cell_type": "markdown",
152 | "source": "### Instantiate an Automated ML Config"
153 | },
154 | {
155 | "metadata": {
156 | "trusted": true
157 | },
158 | "cell_type": "code",
159 | "source": "automl_config = AutoMLConfig(task = 'regression',\n iterations = 100,\n iteration_timeout_minutes = 10, \n max_cores_per_iteration = 10,\n preprocess= True,\n primary_metric='r2_score',\n n_cross_validations = 5,\n debug_log = 'automl.log',\n verbosity = logging.INFO,\n data_script = project_folder + \"/get_data.py\",\n compute_target = compute_target,\n blacklist_models = \"\",\n path = project_folder)",
160 | "execution_count": 19,
161 | "outputs": []
162 | },
163 | {
164 | "metadata": {},
165 | "cell_type": "markdown",
166 | "source": "### Run our Experiment on AML Compute"
167 | },
168 | {
169 | "metadata": {
170 | "trusted": true
171 | },
172 | "cell_type": "code",
173 | "source": "remote_run = experiment.submit(automl_config, show_output=False)\nremote_run",
174 | "execution_count": 20,
175 | "outputs": [
176 | {
177 | "output_type": "execute_result",
178 | "execution_count": 20,
179 | "data": {
180 | "text/html": "",
181 | "text/plain": "Run(Experiment: automl-regression,\nId: AutoML_99de1c5a-78e3-4f33-ac20-36e4b02eec20,\nType: automl,\nStatus: Preparing)"
182 | },
183 | "metadata": {}
184 | }
185 | ]
186 | },
187 | {
188 | "metadata": {},
189 | "cell_type": "markdown",
190 | "source": "### Display Workspace Experiments"
191 | },
192 | {
193 | "metadata": {
194 | "trusted": true
195 | },
196 | "cell_type": "code",
197 | "source": "ws = Workspace.from_config()\nexperiment_list = Experiment.list(workspace=ws)\n\nsummary_df = pd.DataFrame(index = ['No of Runs'])\npattern = re.compile('^AutoML_[^_]*$')\nfor experiment in experiment_list:\n all_runs = list(experiment.get_runs())\n automl_runs = []\n for run in all_runs:\n if(pattern.match(run.id)):\n automl_runs.append(run) \n summary_df[experiment.name] = [len(automl_runs)]\n \npd.set_option('display.max_colwidth', -1)\nsummary_df.T",
198 | "execution_count": 5,
199 | "outputs": [
200 | {
201 | "output_type": "stream",
202 | "text": "Found the config file in: /home/nbuser/library/aml_config/config.json\n",
203 | "name": "stdout"
204 | },
205 | {
206 | "output_type": "execute_result",
207 | "execution_count": 5,
208 | "data": {
209 | "text/html": "\n\n
\n \n \n | \n No of Runs | \n
\n \n \n \n automl-regression | \n 5 | \n
\n \n
\n
",
210 | "text/plain": " No of Runs\nautoml-regression 5 "
211 | },
212 | "metadata": {}
213 | }
214 | ]
215 | },
216 | {
217 | "metadata": {},
218 | "cell_type": "markdown",
219 | "source": "### Display Automated ML Runs for the Experiment"
220 | },
221 | {
222 | "metadata": {
223 | "trusted": true,
224 | "scrolled": true
225 | },
226 | "cell_type": "code",
227 | "source": "proj = ws.experiments[experiment_name]\nsummary_df = pd.DataFrame(index = ['Type', 'Status', 'Primary Metric', 'Iterations', 'Compute', 'Name'])\npattern = re.compile('^AutoML_[^_]*$')\nall_runs = list(proj.get_runs(properties={'azureml.runsource': 'automl'}))\nfor run in all_runs:\n if(pattern.match(run.id)):\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 \nfrom IPython.display import HTML\nprojname_html = HTML(\"{}
\".format(proj.name))\n\nfrom IPython.display import display\ndisplay(projname_html)\ndisplay(summary_df.T)",
228 | "execution_count": 6,
229 | "outputs": [
230 | {
231 | "output_type": "display_data",
232 | "data": {
233 | "text/html": "automl-regression
",
234 | "text/plain": ""
235 | },
236 | "metadata": {}
237 | },
238 | {
239 | "output_type": "display_data",
240 | "data": {
241 | "text/html": "\n\n
\n \n \n | \n Type | \n Status | \n Primary Metric | \n Iterations | \n Compute | \n Name | \n
\n \n \n \n AutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2 | \n regression | \n Completed | \n r2_score | \n 100 | \n d12-cluster | \n automl-regression | \n
\n \n AutoML_e73345b0-5094-4bbe-970b-06f4521da5dd | \n regression | \n Completed | \n r2_score | \n 10 | \n d12-cluster | \n automl-regression | \n
\n \n AutoML_1e6dd094-9885-4998-a2d0-0a598956ed65 | \n regression | \n Completed | \n r2_score | \n 10 | \n d12-cluster | \n automl-regression | \n
\n \n AutoML_3e948b39-bab0-4cd5-bb60-fb3bdcc79e7e | \n regression | \n Completed | \n r2_score | \n 10 | \n d12-cluster | \n automl-regression | \n
\n \n AutoML_3ce57e56-58bb-45ab-923a-aa10393a4837 | \n regression | \n NotStarted | \n r2_score | \n 10 | \n d12-cluster | \n automl-regression | \n
\n \n
\n
",
242 | "text/plain": " Type Status \\\nAutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2 regression Completed \nAutoML_e73345b0-5094-4bbe-970b-06f4521da5dd regression Completed \nAutoML_1e6dd094-9885-4998-a2d0-0a598956ed65 regression Completed \nAutoML_3e948b39-bab0-4cd5-bb60-fb3bdcc79e7e regression Completed \nAutoML_3ce57e56-58bb-45ab-923a-aa10393a4837 regression NotStarted \n\n Primary Metric Iterations \\\nAutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2 r2_score 100 \nAutoML_e73345b0-5094-4bbe-970b-06f4521da5dd r2_score 10 \nAutoML_1e6dd094-9885-4998-a2d0-0a598956ed65 r2_score 10 \nAutoML_3e948b39-bab0-4cd5-bb60-fb3bdcc79e7e r2_score 10 \nAutoML_3ce57e56-58bb-45ab-923a-aa10393a4837 r2_score 10 \n\n Compute Name \nAutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2 d12-cluster automl-regression \nAutoML_e73345b0-5094-4bbe-970b-06f4521da5dd d12-cluster automl-regression \nAutoML_1e6dd094-9885-4998-a2d0-0a598956ed65 d12-cluster automl-regression \nAutoML_3e948b39-bab0-4cd5-bb60-fb3bdcc79e7e d12-cluster automl-regression \nAutoML_3ce57e56-58bb-45ab-923a-aa10393a4837 d12-cluster automl-regression "
243 | },
244 | "metadata": {}
245 | }
246 | ]
247 | },
248 | {
249 | "metadata": {},
250 | "cell_type": "markdown",
251 | "source": "### Display Automated ML Run Details"
252 | },
253 | {
254 | "metadata": {
255 | "trusted": true
256 | },
257 | "cell_type": "code",
258 | "source": "run_id = 'AutoML_ab755820-4bfd-4e8a-8b4b-9e0a2446b1c2' \n\nfrom azureml.widgets import RunDetails\n\nexperiment = Experiment(ws, experiment_name)\nml_run = AutoMLRun(experiment=experiment, run_id=run_id)\n\nRunDetails(ml_run).show() ",
259 | "execution_count": 15,
260 | "outputs": [
261 | {
262 | "output_type": "display_data",
263 | "data": {
264 | "application/vnd.jupyter.widget-view+json": {
265 | "model_id": "b6746b6eb6c64c3895e171d40efe55d3",
266 | "version_minor": 0,
267 | "version_major": 2
268 | },
269 | "text/plain": "_AutoMLWidget(widget_settings={'childWidgetDisplay': 'popup', 'send_telemetry': False, 'log_level': 'NOTSET', …"
270 | },
271 | "metadata": {}
272 | }
273 | ]
274 | },
275 | {
276 | "metadata": {},
277 | "cell_type": "markdown",
278 | "source": "### Show best run and model"
279 | },
280 | {
281 | "metadata": {
282 | "trusted": true,
283 | "scrolled": true
284 | },
285 | "cell_type": "code",
286 | "source": "best_run, fitted_model = ml_run.get_output()\nprint(best_run)\nprint(fitted_model)",
287 | "execution_count": null,
288 | "outputs": []
289 | },
290 | {
291 | "metadata": {
292 | "trusted": true
293 | },
294 | "cell_type": "code",
295 | "source": "# show run and model from metric\nlookup_metric = \"root_mean_squared_error\"\nbest_run, fitted_model = ml_run.get_output(metric = lookup_metric)\nprint(best_run)\nprint(fitted_model)",
296 | "execution_count": null,
297 | "outputs": []
298 | },
299 | {
300 | "metadata": {
301 | "trusted": true
302 | },
303 | "cell_type": "code",
304 | "source": "# show run and model from iteration 3\niteration = 3\nthird_run, third_model = ml_run.get_output(iteration=iteration)\nprint(third_run)\nprint(third_model)",
305 | "execution_count": null,
306 | "outputs": []
307 | },
308 | {
309 | "metadata": {},
310 | "cell_type": "markdown",
311 | "source": "### Deploy the Model to AKS"
312 | },
313 | {
314 | "metadata": {
315 | "trusted": true
316 | },
317 | "cell_type": "code",
318 | "source": "# register the model for deployment\nmodel = Model.register(model_path = \"model.pkl\",\n model_name = \"model.pkl\",\n tags = {'area': \"auto\", 'type': \"regression\"},\n description = \"Contoso Auto model to predict battery failure\",\n workspace = ws)\n\nprint(model.name, model.description, model.version)",
319 | "execution_count": 49,
320 | "outputs": [
321 | {
322 | "output_type": "stream",
323 | "text": "Registering model model.pkl\nmodel.pkl Contoso Auto model to predict battery failure 4\n",
324 | "name": "stdout"
325 | }
326 | ]
327 | },
328 | {
329 | "metadata": {},
330 | "cell_type": "markdown",
331 | "source": "### Create Scoring File"
332 | },
333 | {
334 | "metadata": {
335 | "trusted": true
336 | },
337 | "cell_type": "code",
338 | "source": "%%writefile score.py\nimport pickle\nimport json\nimport numpy\nimport azureml.train.automl\nfrom sklearn.externals import joblib\nfrom azureml.core.model import Model\n\ndef init():\n global model\n model_path = Model.get_model_path('model.pkl') # this name is model.id of model that we want to deploy\n # deserialize the model file back into a sklearn model\n model = joblib.load(model_path)\n\ndef run(rawdata):\n try:\n data = json.loads(rawdata)['data']\n data = numpy.array(data)\n result = model.predict(data)\n except Exception as e:\n result = str(e)\n return json.dumps({\"error\": result})\n return json.dumps({\"result\":result.tolist()})",
339 | "execution_count": 79,
340 | "outputs": [
341 | {
342 | "output_type": "stream",
343 | "text": "Overwriting score.py\n",
344 | "name": "stdout"
345 | }
346 | ]
347 | },
348 | {
349 | "metadata": {},
350 | "cell_type": "markdown",
351 | "source": "### Create Environment Dependency File"
352 | },
353 | {
354 | "metadata": {
355 | "trusted": true
356 | },
357 | "cell_type": "code",
358 | "source": "from azureml.core.conda_dependencies import CondaDependencies \n\nmyenv = CondaDependencies.create(conda_packages=['numpy','scikit-learn'],pip_packages=['azureml-sdk[notebooks,automl]'])\nprint(myenv.serialize_to_string())\n\nwith open(\"myenv.yml\",\"w\") as f:\n f.write(myenv.serialize_to_string())",
359 | "execution_count": 59,
360 | "outputs": [
361 | {
362 | "output_type": "stream",
363 | "text": "# Conda environment specification. The dependencies defined in this file will\r\n# be automatically provisioned for runs with userManagedDependencies=False.\r\n\n# Details about the Conda environment file format:\r\n# https://conda.io/docs/user-guide/tasks/manage-environments.html#create-env-file-manually\r\n\nname: project_environment\ndependencies:\n # The python interpreter version.\r\n # Currently Azure ML only supports 3.5.2 and later.\r\n- python=3.6.2\n\n- pip:\n - azureml-sdk[notebooks,automl]==0.1.80\n- numpy\n- scikit-learn\n\n",
364 | "name": "stdout"
365 | }
366 | ]
367 | },
368 | {
369 | "metadata": {},
370 | "cell_type": "markdown",
371 | "source": "### Create Container Image"
372 | },
373 | {
374 | "metadata": {
375 | "trusted": true
376 | },
377 | "cell_type": "code",
378 | "source": "from azureml.core.image import ContainerImage\n\nimage_config = ContainerImage.image_configuration(execution_script = \"score.py\",\n runtime = \"python\",\n conda_file = \"myenv.yml\",\n description = \"Image with regression model\",\n tags = {'area': \"auto\", 'type': \"regression\"}\n )\n\nimage = ContainerImage.create(name = \"myimage1\",\n # this is the model object\n models = [model],\n image_config = image_config,\n workspace = ws)\n\nimage.wait_for_creation(show_output = True)",
379 | "execution_count": 80,
380 | "outputs": [
381 | {
382 | "output_type": "stream",
383 | "text": "Creating image\nRunning..................................................\nSucceededImage creation operation finished for image myimage1:11, operation \"Succeeded\"\n",
384 | "name": "stdout"
385 | }
386 | ]
387 | },
388 | {
389 | "metadata": {
390 | "trusted": true
391 | },
392 | "cell_type": "code",
393 | "source": "print(model.name, model.description, model.version)",
394 | "execution_count": 61,
395 | "outputs": [
396 | {
397 | "output_type": "stream",
398 | "text": "model.pkl Contoso Auto model to predict battery failure 4\n",
399 | "name": "stdout"
400 | }
401 | ]
402 | },
403 | {
404 | "metadata": {},
405 | "cell_type": "markdown",
406 | "source": "### Create AKS Compute Cluster"
407 | },
408 | {
409 | "metadata": {
410 | "trusted": true
411 | },
412 | "cell_type": "code",
413 | "source": "try:\n # attach to existing cluster\n aks_target = AksCompute.attach_configuration(resource_group,aks_cluster_name)\n print('Found existing compute target.')\n\nexcept ComputeTargetException:\n print('Creating a new compute target...')\n \n # Use the default configuration (can also provide parameters to customize)\n prov_config = AksCompute.provisioning_configuration()\n \n # Create the cluster\n aks_target = ComputeTarget.create(workspace = ws, \n name = aks_cluster_name, \n provisioning_configuration = prov_config)\n \n aks_target.wait_for_completion(True)",
414 | "execution_count": 18,
415 | "outputs": [
416 | {
417 | "output_type": "stream",
418 | "text": "Found existing compute target.\n",
419 | "name": "stdout"
420 | }
421 | ]
422 | },
423 | {
424 | "metadata": {
425 | "trusted": true
426 | },
427 | "cell_type": "code",
428 | "source": "%%time\naks_target.wait_for_completion(show_output = True)\nprint(aks_target.provisioning_state)\nprint(aks_target.provisioning_errors)",
429 | "execution_count": 63,
430 | "outputs": [
431 | {
432 | "output_type": "stream",
433 | "text": "SucceededProvisioning operation finished, operation \"Succeeded\"\nSucceeded\nNone\nCPU times: user 132 ms, sys: 19.2 ms, total: 151 ms\nWall time: 1.77 s\n",
434 | "name": "stdout"
435 | }
436 | ]
437 | },
438 | {
439 | "metadata": {},
440 | "cell_type": "markdown",
441 | "source": "### Activate Data Collection and App Insights"
442 | },
443 | {
444 | "metadata": {
445 | "trusted": true
446 | },
447 | "cell_type": "code",
448 | "source": "aks_config = AksWebservice.deploy_configuration(collect_model_data=True, enable_app_insights=True)",
449 | "execution_count": 34,
450 | "outputs": []
451 | },
452 | {
453 | "metadata": {},
454 | "cell_type": "markdown",
455 | "source": "### Deploy AKS Service"
456 | },
457 | {
458 | "metadata": {
459 | "trusted": true
460 | },
461 | "cell_type": "code",
462 | "source": "%%time\naks_service_name ='aks-automl-service'\n\naks_service = Webservice.deploy_from_image(workspace = ws, \n name = aks_service_name,\n image = image,\n deployment_config = aks_config,\n deployment_target = aks_target\n )\naks_service.wait_for_deployment(show_output = True)\nprint(aks_service.state)",
463 | "execution_count": 81,
464 | "outputs": [
465 | {
466 | "output_type": "stream",
467 | "text": "Creating service\nRunning..........\nSucceededAKS service creation operation finished, operation \"Succeeded\"\nHealthy\nCPU times: user 2.91 s, sys: 1.99 s, total: 4.91 s\nWall time: 1min 35s\n",
468 | "name": "stdout"
469 | }
470 | ]
471 | },
472 | {
473 | "metadata": {},
474 | "cell_type": "markdown",
475 | "source": "### Let's send some data to our deployed model for scoring"
476 | },
477 | {
478 | "metadata": {
479 | "trusted": true
480 | },
481 | "cell_type": "code",
482 | "source": "# connect to our deployed webservice\naks_service_name ='aml-deployment'\naks_service = Webservice(ws,aks_service_name)",
483 | "execution_count": 33,
484 | "outputs": []
485 | },
486 | {
487 | "metadata": {
488 | "trusted": true
489 | },
490 | "cell_type": "code",
491 | "source": "%%time\nimport json\n\ntest_sample = json.dumps({'data': [\n['IN',19.15495,6.384985,4.418251,1.104563,275,'13/07/18 2:22',0.9895812,'TRUE',2.8514,-2.421932,1.803821,0.1420937,19.41035,-10.33971,4.994291,-3.19803,0.5932726,-0.2799033,3.762096,-5.902425,0.2882381,-5.905498,8.741195,-0.4245991,2.395039,-0.7456794,6.898268,-1.127218,1.703492,-5.752116,3.996971,-8.95153,10.22003,-1.595172,2.247191,-1.121793,4.996044,-6.837433,4.78311,-6.228294,0.7635236,-1.651543,3.320588,-4.662266,8.282479,-7.533159,3.42775,-5.83142,3.538565,-8.041959,5.604261,-7.598347,2.287185,-3.965398,-0.2936086,-4.733507,0.7539286,-8.021865,-0.3866819,-5.818779,1.083508,-5.754504,0.2697741,-4.017708,6.618633,-4.793797,0.9704788,-8.445375,7.017274,-4.309704],\n['KY',12.76638,4.255461,4.637216,1.159304,200,'31/05/02 15:13',0.9818932,'TRUE',22.46028,9.091237,11.33573,5.214643,22.17157,14.34025,14.84693,13.49144,19.34599,9.316383,11.15997,11.23271,14.11339,12.19635,11.55645,14.43205,15.46946,14.89094,9.404753,10.79446,19.93939,3.656265,20.31931,10.68032,26.11576,13.04341,27.57416,13.69934,15.96372,8.091751,20.2443,12.82367,26.48169,14.26837,13.91523,9.974995,11.60701,15.51763,10.1793,14.61067,12.57748,5.229428,12.98358,14.08325,16.73077,11.02146,12.44928,11.49129,22.54166,15.08719,14.38561,8.998335,17.21011,7.226648,24.4104,15.72218,9.494973,5.325149,24.37264,10.20268,28.17513,10.04264],\n['CT',12.21648,4.072161,4.573806,1.143452,300,'1/03/12 10:50',0.98971,'TRUE',-1.658414,-10.9939,-1.937163,-10.25981,-1.195308,-8.606098,-1.554342,-12.70384,0.2668873,-7.691629,2.69716,-7.51222,-2.9216,-7.60612,-0.5862359,-7.609216,-1.873049,-9.402542,-2.002848,-8.135921,-1.871041,-7.266486,-2.711555,-11.66985,-0.9914851,-8.3723,-2.391308,-14.49702,-2.501041,-11.94528,-3.126329,-7.522929,-1.936209,-8.830083,-2.998604,-10.97404,-2.545327,-13.96437,-2.980918,-8.183976,0.311937,-9.154572,-3.293516,-9.396478,-2.792858,-7.689294,-2.446307,-11.11649,-1.908358,-8.362305,-1.170622,-9.072707,-2.672267,-7.925601,-3.069303,-9.646969,-0.07557144,-11.04824,-3.105785,-12.43558,-2.232244,-8.368411],\n['CT',9.625083,3.208361,4.705291,1.176323,275,'25/11/16 22:08',0.865485,'FALSE',-1.658414,-10.9939,-1.937163,-10.25981,-1.195308,-8.606098,-1.554342,-12.70384,0.2668873,-7.691629,2.69716,-7.51222,-2.9216,-7.60612,-0.5862359,-7.609216,-1.873049,-9.402542,-2.002848,-8.135921,-1.871041,-7.266486,-2.711555,-11.66985,-0.9914851,-8.3723,-2.391308,-14.49702,-2.501041,-11.94528,-3.126329,-7.522929,-1.936209,-8.830083,-2.998604,-10.97404,-2.545327,-13.96437,-2.980918,-8.183976,0.311937,-9.154572,-3.293516,-9.396478,-2.792858,-7.689294,-2.446307,-11.11649,-1.908358,-8.362305,-1.170622,-9.072707,-2.672267,-7.925601,-3.069303,-9.646969,-0.07557144,-11.04824,-3.105785,-12.43558,-2.232244,-8.368411],\n['FL',17.85818,5.952728,4.399894,1.099974,300,'25/11/01 18:16',0.7642509,'FALSE',10.32168,5.872889,21.95105,-2.874581,6.51763,-8.621648,4.058293,3.500825,3.892226,3.077705,6.820755,2.913943,10.62536,5.937967,11.18945,6.205084,10.6432,-7.265468,3.760776,-4.693088,24.2411,-4.036252,12.14198,1.464403,12.32776,1.994331,9.493693,-1.086546,7.849817,2.205197,5.746057,4.358121,9.027902,0.1798456,16.78342,-9.455979,4.034511,-0.1012211,4.810216,-5.615338,11.73815,1.85157,3.611376,-1.954806,11.6319,3.41892,3.517238,0.5853885,4.945271,4.676959,6.96969,5.579078,17.6168,3.732666,12.09296,4.426332,6.20668,4.294805,14.51202,-3.4485,17.5475,1.991567],\n['DE',17.28716,5.762388,4.283211,1.070803,300,'27/07/17 19:45',0.5777664,'FALSE',13.96078,-2.754078,17.8166,-0.2489798,11.93943,5.435248,19.21992,6.727683,10.08444,-3.310574,7.241928,7.051814,17.85883,-7.081769,14.22044,3.07837,16.71284,7.325282,19.33307,4.639416,13.89478,6.945053,6.215093,-4.174345,11.39258,2.341135,9.024965,-0.9651989,16.30217,5.354174,32.52575,5.573918,21.19589,6.123736,16.65708,5.262541,8.372107,-3.219587,7.835368,0.922116,12.77252,-2.981667,8.253579,-1.587934,8.729166,5.412447,5.57432,3.338246,13.58406,5.452766,11.59805,3.547957,11.75507,5.498366,15.33035,4.497998,3.521219,-3.946181,11.73532,-2.694235,2.978961,2.05522],\n['DC',17.28162,5.76054,4.86257,1.215642,275,'16/05/01 5:59',0.9208778,'TRUE',7.469709,10.6893,18.29722,7.559317,8.489743,-3.168853,14.71674,8.316207,15.70391,8.286606,10.54364,4.470983,9.806995,3.455532,15.32086,8.475863,16.6405,-2.045821,12.9084,9.461186,12.23517,3.18436,9.566648,5.912929,8.566251,9.410266,22.97381,8.462457,30.01167,1.056327,5.733205,2.561738,15.91757,8.504434,9.987944,9.57527,8.520579,-5.626044,9.433581,8.790739,6.544751,9.22794,6.936818,4.144661,10.32389,6.937299,13.75679,-0.6973994,9.777148,2.489468,6.443116,4.349396,15.84071,2.015728,14.64257,8.044127,9.416532,6.192503,7.30854,2.94854,8.068276,4.816947],\n['FL',15.12272,5.040905,4.783088,1.195772,300,'1/12/02 14:11',0.9664124,'FALSE',10.32168,5.872889,21.95105,-2.874581,6.51763,-8.621648,4.058293,3.500825,3.892226,3.077705,6.820755,2.913943,10.62536,5.937967,11.18945,6.205084,10.6432,-7.265468,3.760776,-4.693088,24.2411,-4.036252,12.14198,1.464403,12.32776,1.994331,9.493693,-1.086546,7.849817,2.205197,5.746057,4.358121,9.027902,0.1798456,16.78342,-9.455979,4.034511,-0.1012211,4.810216,-5.615338,11.73815,1.85157,3.611376,-1.954806,11.6319,3.41892,3.517238,0.5853885,4.945271,4.676959,6.96969,5.579078,17.6168,3.732666,12.09296,4.426332,6.20668,4.294805,14.51202,-3.4485,17.5475,1.991567]\n]})\ntest_sample = bytes(test_sample,encoding = 'utf8')\n\nprediction = aks_service.run(input_data = test_sample)\nprint(prediction)",
492 | "execution_count": 44,
493 | "outputs": [
494 | {
495 | "output_type": "stream",
496 | "text": "{\"result\": [1358.0364919856179, 1165.4468685286188, 1974.4219433798783, 2060.783847563827, 1875.5603215853744, 2160.4825013262944, 1455.8311329305204, 1715.142822632055]}\nCPU times: user 1.25 s, sys: 583 ms, total: 1.83 s\nWall time: 1.57 s\n",
497 | "name": "stdout"
498 | }
499 | ]
500 | },
501 | {
502 | "metadata": {
503 | "trusted": true
504 | },
505 | "cell_type": "code",
506 | "source": "",
507 | "execution_count": null,
508 | "outputs": []
509 | }
510 | ],
511 | "metadata": {
512 | "kernelspec": {
513 | "name": "python36",
514 | "display_name": "Python 3.6",
515 | "language": "python"
516 | },
517 | "language_info": {
518 | "mimetype": "text/x-python",
519 | "nbconvert_exporter": "python",
520 | "name": "python",
521 | "pygments_lexer": "ipython3",
522 | "version": "3.6.6",
523 | "file_extension": ".py",
524 | "codemirror_mode": {
525 | "version": 3,
526 | "name": "ipython"
527 | }
528 | }
529 | },
530 | "nbformat": 4,
531 | "nbformat_minor": 2
532 | }
--------------------------------------------------------------------------------
/Connected Car Demo/model.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nthacker/aml-demos/bff2ac2b18a4e6e13b139af54d15468076a7bb53/Connected Car Demo/model.pkl
--------------------------------------------------------------------------------
/Connected Car Demo/myenv-1.0.2.yml:
--------------------------------------------------------------------------------
1 | # Conda environment specification. The dependencies defined in this file will
2 | # be automatically provisioned for runs with userManagedDependencies=False.
3 |
4 | # Details about the Conda environment file format:
5 | # https://conda.io/docs/user-guide/tasks/manage-environments.html#create-env-file-manually
6 |
7 | name: project_environment
8 | dependencies:
9 | # The python interpreter version.
10 | # Currently Azure ML only supports 3.5.2 and later.
11 | - python=3.6.2
12 |
13 | - pip:
14 | - azureml-sdk[automl]==0.1.80
15 | - numpy
16 | - scikit-learn
17 |
--------------------------------------------------------------------------------
/Connected Car Demo/myenv.yml:
--------------------------------------------------------------------------------
1 | # Conda environment specification. The dependencies defined in this file will
2 | # be automatically provisioned for runs with userManagedDependencies=False.
3 |
4 | # Details about the Conda environment file format:
5 | # https://conda.io/docs/user-guide/tasks/manage-environments.html#create-env-file-manually
6 |
7 | name: project_environment
8 | dependencies:
9 | # The python interpreter version.
10 | # Currently Azure ML only supports 3.5.2 and later.
11 | - python=3.6.2
12 |
13 | - pip:
14 | - azureml-sdk[automl]==1.0.2
15 | - numpy
16 | - scikit-learn
17 |
--------------------------------------------------------------------------------
/Connected Car Demo/score.py:
--------------------------------------------------------------------------------
1 | import pickle
2 | import json
3 | import numpy
4 | import azureml.train.automl
5 | from sklearn.externals import joblib
6 | from azureml.core.model import Model
7 |
8 | def init():
9 | global model
10 | model_path = Model.get_model_path('model.pkl') # this name is model.id of model that we want to deploy
11 | # deserialize the model file back into a sklearn model
12 | model = joblib.load(model_path)
13 |
14 | def run(rawdata):
15 | try:
16 | data = json.loads(rawdata)['data']
17 | data = numpy.array(data)
18 | result = model.predict(data)
19 | except Exception as e:
20 | result = str(e)
21 | return json.dumps({"error": result})
22 | return json.dumps({"result":result.tolist()})
23 |
--------------------------------------------------------------------------------
/Connected Car Demo/telemetry.log:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nthacker/aml-demos/bff2ac2b18a4e6e13b139af54d15468076a7bb53/Connected Car Demo/telemetry.log
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Azure Machine Learning service demos
2 | This repo is created to host AML service demos and samples. The repo is public under a Creative Commons license, and users are encouraged to contribute new demos to this repo.
3 |
4 | We will keep adding more demos to this repo as they become available.
5 |
6 | P.S.: Microsoft doesn't take any responsibility for correctness or production readiness of code published in this demo.
7 |
--------------------------------------------------------------------------------