Update notebooks

This commit is contained in:
Roope Astala
2018-09-17 15:51:23 -04:00
parent 65e56a954e
commit fe06e2116b
57 changed files with 15506 additions and 140 deletions

View File

@@ -560,7 +560,7 @@
"metadata": {},
"outputs": [],
"source": [
"run.wait_for_completion(show_output=True) # specify True for a verbose log"
"run.wait_for_completion(show_output=False) # specify True for a verbose log"
]
},
{

View File

@@ -196,7 +196,7 @@
"\n",
"conf_mx = confusion_matrix(y_test, y_hat)\n",
"print(conf_mx)\n",
"print('Overall accuracy:', np.average(y_hat == y_test))"
"print('Overall accuracy:', np.average(y_hat==y_test))"
]
},
{
@@ -313,7 +313,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Review the content of the file"
"Review the content of the `myenv.yml` file."
]
},
{
@@ -322,7 +322,8 @@
"metadata": {},
"outputs": [],
"source": [
"%pfile myenv.yml"
"with open(\"myenv.yml\",\"r\") as f:\n",
" print(f.read())"
]
},
{
@@ -383,7 +384,7 @@
" conda_file=\"myenv.yml\")\n",
"\n",
"service = Webservice.deploy_from_model(workspace=ws,\n",
" name='sklearn-mnist-model',\n",
" name='sklearn-mnist-svc',\n",
" deployment_config=aciconfig,\n",
" models=[model],\n",
" image_config=image_config)\n",
@@ -463,6 +464,40 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also send raw HTTP request to test the web service."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"\n",
"# send a random row from the test set to score\n",
"random_index = np.random.randint(0, len(X_test)-1)\n",
"input_data = \"{\\\"data\\\": [\" + str(list(X_test[random_index])) + \"]}\"\n",
"\n",
"headers = {'Content-Type':'application/json'}\n",
"\n",
"# for AKS deployment you'd need to the service key in the header as well\n",
"# api_key = service.get_key()\n",
"# headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)} \n",
"\n",
"resp = requests.post(service.scoring_uri, input_data, headers=headers)\n",
"\n",
"print(\"POST to url\", service.scoring_uri)\n",
"#print(\"input data:\", input_data)\n",
"print(\"label:\", y_test[random_index])\n",
"print(\"prediction:\", resp.text)"
]
},
{
"cell_type": "markdown",
"metadata": {},