fix : image path
|
@ -63,7 +63,7 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<img src=\"../docs/images/azureml-workspace.png\" width=500>\n"
|
||||
"<img src=\"docs/images/azureml-workspace.png\" width=500>"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -76,7 +76,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649081976581
|
||||
|
@ -91,7 +91,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649081976640
|
||||
|
@ -134,7 +134,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649081976707
|
||||
|
@ -157,7 +157,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649081977548
|
||||
|
@ -177,7 +177,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649081977662
|
||||
|
@ -191,7 +191,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649081977755
|
||||
|
@ -206,88 +206,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{\n",
|
||||
" \"databricks\": {\n",
|
||||
" \"eggLibraries\": [],\n",
|
||||
" \"jarLibraries\": [],\n",
|
||||
" \"mavenLibraries\": [],\n",
|
||||
" \"pypiLibraries\": [],\n",
|
||||
" \"rcranLibraries\": []\n",
|
||||
" },\n",
|
||||
" \"docker\": {\n",
|
||||
" \"arguments\": [],\n",
|
||||
" \"baseDockerfile\": null,\n",
|
||||
" \"baseImage\": \"mcr.microsoft.com/azureml/openmpi3.1.2-ubuntu18.04:20220208.v1\",\n",
|
||||
" \"baseImageRegistry\": {\n",
|
||||
" \"address\": null,\n",
|
||||
" \"password\": null,\n",
|
||||
" \"registryIdentity\": null,\n",
|
||||
" \"username\": null\n",
|
||||
" },\n",
|
||||
" \"enabled\": false,\n",
|
||||
" \"platform\": {\n",
|
||||
" \"architecture\": \"amd64\",\n",
|
||||
" \"os\": \"Linux\"\n",
|
||||
" },\n",
|
||||
" \"sharedVolumes\": true,\n",
|
||||
" \"shmSize\": null\n",
|
||||
" },\n",
|
||||
" \"environmentVariables\": {\n",
|
||||
" \"AZUREML_ENTRY_SCRIPT\": \"script/score.py\",\n",
|
||||
" \"AZUREML_SOURCE_DIRECTORY\": \"script\",\n",
|
||||
" \"EXAMPLE_ENV_VAR\": \"EXAMPLE_VALUE\"\n",
|
||||
" },\n",
|
||||
" \"inferencingStackVersion\": null,\n",
|
||||
" \"name\": \"lightgbm-python-env\",\n",
|
||||
" \"python\": {\n",
|
||||
" \"baseCondaEnvironment\": null,\n",
|
||||
" \"condaDependencies\": {\n",
|
||||
" \"channels\": [\n",
|
||||
" \"anaconda\",\n",
|
||||
" \"conda-forge\"\n",
|
||||
" ],\n",
|
||||
" \"dependencies\": [\n",
|
||||
" \"python=3.8\",\n",
|
||||
" {\n",
|
||||
" \"pip\": [\n",
|
||||
" \"lightgbm==3.3.1\",\n",
|
||||
" \"matplotlib==3.5.1\",\n",
|
||||
" \"scikit-learn==1.0.2\",\n",
|
||||
" \"pandas==1.4.2\",\n",
|
||||
" \"ipykernel==6.12.1\",\n",
|
||||
" \"pytest==7.1.1\",\n",
|
||||
" \"inference-schema[numpy-support]==1.3.2\",\n",
|
||||
" \"azureml-mlflow==1.40.0\",\n",
|
||||
" \"azureml-dataprep==3.0.1\",\n",
|
||||
" \"azureml-defaults==1.40.0\"\n",
|
||||
" ]\n",
|
||||
" }\n",
|
||||
" ],\n",
|
||||
" \"name\": \"azureml_5d2a131ca6625ee301a6ddb4e2abfbec\"\n",
|
||||
" },\n",
|
||||
" \"condaDependenciesFile\": null,\n",
|
||||
" \"interpreterPath\": \"python\",\n",
|
||||
" \"userManagedDependencies\": false\n",
|
||||
" },\n",
|
||||
" \"r\": null,\n",
|
||||
" \"spark\": {\n",
|
||||
" \"packages\": [],\n",
|
||||
" \"precachePackages\": true,\n",
|
||||
" \"repositories\": []\n",
|
||||
" },\n",
|
||||
" \"version\": \"16\"\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"env"
|
||||
]
|
||||
|
@ -304,26 +223,29 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"```python\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"import json\n",
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd\n",
|
||||
"import lightgbm as lgb\n",
|
||||
"from helper import data_preprocess\n",
|
||||
"\n",
|
||||
"def data_preprocess(df, categorical_cols, float_cols):\n",
|
||||
" df[categorical_cols] = df[categorical_cols].astype('category')\n",
|
||||
" df[float_cols] = df[float_cols].astype('float')\n",
|
||||
" return df\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def init():\n",
|
||||
" global bst\n",
|
||||
" model_root = os.getenv(\"AZUREML_MODEL_DIR\")\n",
|
||||
" # 学習済みモデルを含むフォルダ名の指定\n",
|
||||
" # The name of the folder in which to look for LightGBM model files\n",
|
||||
" lgbm_model_folder = \"model\"\n",
|
||||
" bst = lgb.Booster(\n",
|
||||
" model_file=os.path.join(model_root, lgbm_model_folder, \"model.lgb\")\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def run(raw_data):\n",
|
||||
" categorical_cols = ['Name', 'Sex', 'Ticket', 'Cabin', 'Embarked']\n",
|
||||
" float_cols = ['Pclass', 'Age', 'SibSp', 'Parch', 'Fare']\n",
|
||||
|
@ -331,11 +253,9 @@
|
|||
" data = np.array(json.loads(raw_data)[\"data\"])\n",
|
||||
" test_df_original = pd.DataFrame(data=data, columns=columns)\n",
|
||||
" test_df = data_preprocess(test_df_original, categorical_cols, float_cols)\n",
|
||||
" # 予測値の生成\n",
|
||||
" # Make prediction\n",
|
||||
" out = bst.predict(test_df)\n",
|
||||
" return out.tolist()\n",
|
||||
"\n",
|
||||
"````"
|
||||
" return out.tolist()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -353,7 +273,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649081977843
|
||||
|
@ -388,7 +308,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649082310789
|
||||
|
@ -403,39 +323,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Downloading model lgb-model:3 to /tmp/azureml_gy6lj6_p/lgb-model/3\n",
|
||||
"Generating Docker build context.\n",
|
||||
"Package creation Succeeded\n",
|
||||
"Logging into Docker registry ftamlacrnwdem.azurecr.io\n",
|
||||
"Logging into Docker registry ftamlacrnwdem.azurecr.io\n",
|
||||
"Building Docker image from Dockerfile...\n",
|
||||
"Step 1/5 : FROM ftamlacrnwdem.azurecr.io/azureml/azureml_e51c371367728f42a881ccad677344ed\n",
|
||||
" ---> 6f9f959b4c84\n",
|
||||
"Step 2/5 : COPY azureml-app /var/azureml-app\n",
|
||||
" ---> 3689828ce76f\n",
|
||||
"Step 3/5 : RUN mkdir -p '/var/azureml-app' && echo eyJhY2NvdW50Q29udGV4dCI6eyJzdWJzY3JpcHRpb25JZCI6IjljMGY5MWI4LWViMmYtNDg0Yy05NzljLTE1ODQ4YzA5OGE2YiIsInJlc291cmNlR3JvdXBOYW1lIjoiZnRhLW1sIiwiYWNjb3VudE5hbWUiOiJmdGFtbGF6dXJlbWwiLCJ3b3Jrc3BhY2VJZCI6IjRiNzYxNzk0LTQ1OWYtNDc2MS1hZWFjLTVjNzRjZTM3YWZkZCJ9LCJtb2RlbHMiOnt9LCJtb2RlbHNJbmZvIjp7fX0= | base64 --decode > /var/azureml-app/model_config_map.json\n",
|
||||
" ---> Running in d4cbf3686ccb\n",
|
||||
" ---> 5948f4fab156\n",
|
||||
"Step 4/5 : RUN mv '/var/azureml-app/tmp7m89nvmj.py' /var/azureml-app/main.py\n",
|
||||
" ---> Running in a1610d329955\n",
|
||||
" ---> 8ca95c816f8b\n",
|
||||
"Step 5/5 : CMD [\"runsvdir\",\"/var/runit\"]\n",
|
||||
" ---> Running in d349b06b211a\n",
|
||||
" ---> 4c158c4eca52\n",
|
||||
"Successfully built 4c158c4eca52\n",
|
||||
"Successfully tagged mylocalmodel:latest\n",
|
||||
"Container has been successfully cleaned up.\n",
|
||||
"Image sha256:fa0c01f6e93fd182c1503094c8cc487e5f3b0b60b134269911030cfc98b5419e successfully removed.\n",
|
||||
"Starting Docker container...\n",
|
||||
"Docker container running.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"localconfig = LocalWebservice.deploy_configuration(port=8890)\n",
|
||||
"local_service_name = \"mylocalmodel\"\n",
|
||||
|
@ -464,7 +352,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649082511636
|
||||
|
@ -479,17 +367,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Checking container health...\n",
|
||||
"Local webservice is running at http://localhost:8890\n",
|
||||
"[[0.7252904642292589, 0.2747095357707411]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
|
@ -538,7 +416,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649082516974
|
||||
|
@ -559,7 +437,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649082517621
|
||||
|
@ -581,7 +459,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649082524737
|
||||
|
@ -602,38 +480,20 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649084385605
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Tips: You can try get_logs(): https://aka.ms/debugimage#dockerlog or local deployment: https://aka.ms/debugimage#debug-locally to debug if deployment takes longer than 10 minutes.\n",
|
||||
"Running\n",
|
||||
"2022-04-06 14:45:03+00:00 Creating Container Registry if not exists.\n",
|
||||
"2022-04-06 14:45:04+00:00 Registering the environment.\n",
|
||||
"2022-04-06 14:45:04+00:00 Use the existing image.\n",
|
||||
"2022-04-06 14:45:04+00:00 Generating deployment configuration.\n",
|
||||
"2022-04-06 14:45:05+00:00 Submitting deployment to compute.\n",
|
||||
"2022-04-06 14:45:09+00:00 Checking the status of deployment lgb-aci3..\n",
|
||||
"2022-04-06 14:45:29+00:00 Checking the status of inference endpoint lgb-aci3.\n",
|
||||
"Succeeded\n",
|
||||
"ACI service creation operation finished, operation \"Succeeded\"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"service.wait_for_deployment(show_output=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649084385651
|
||||
|
@ -648,18 +508,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'2022-04-06T14:45:18,151287655+00:00 - iot-server/run \\n2022-04-06T14:45:18,152994579+00:00 - gunicorn/run \\nDynamic Python package installation is disabled.\\nStarting HTTP server\\n2022-04-06T14:45:18,453755549+00:00 - nginx/run \\n2022-04-06T14:45:18,452391231+00:00 - rsyslog/run \\nEdgeHubConnectionString and IOTEDGE_IOTHUBHOSTNAME are not set. Exiting...\\n2022-04-06T14:45:22,054053936+00:00 - iot-server/finish 1 0\\n2022-04-06T14:45:22,149499568+00:00 - Exit code 1 is normal. Not restarting iot-server.\\nStarting gunicorn 20.1.0\\nListening at: http://127.0.0.1:31311 (13)\\nUsing worker: sync\\nworker timeout is set to 300\\nBooting worker with pid: 38\\nSPARK_HOME not set. Skipping PySpark Initialization.\\nInitializing logger\\n2022-04-06 14:45:38,053 | root | INFO | Starting up app insights client\\nlogging socket was found. logging is available.\\nlogging socket was found. logging is available.\\n2022-04-06 14:45:38,054 | root | INFO | Starting up request id generator\\n2022-04-06 14:45:38,054 | root | INFO | Starting up app insight hooks\\n2022-04-06 14:45:38,054 | root | INFO | Invoking user\\'s init function\\n2022-04-06 14:45:38,152 | root | INFO | Users\\'s init has completed successfully\\n2022-04-06 14:45:38,252 | root | INFO | Skipping middleware: dbg_model_info as it\\'s not enabled.\\n2022-04-06 14:45:38,252 | root | INFO | Skipping middleware: dbg_resource_usage as it\\'s not enabled.\\n2022-04-06 14:45:38,253 | root | INFO | Scoring timeout is found from os.environ: 60000 ms\\n2022-04-06 14:45:38,448 | root | INFO | Swagger file not present\\n2022-04-06 14:45:38,448 | root | INFO | 404\\n127.0.0.1 - - [06/Apr/2022:14:45:38 +0000] \"GET /swagger.json HTTP/1.0\" 404 19 \"-\" \"Go-http-client/1.1\"\\n2022-04-06 14:45:43,038 | root | INFO | Swagger file not present\\n2022-04-06 14:45:43,038 | root | INFO | 404\\n127.0.0.1 - - [06/Apr/2022:14:45:43 +0000] \"GET /swagger.json HTTP/1.0\" 404 19 \"-\" \"Go-http-client/1.1\"\\n'"
|
||||
]
|
||||
},
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"service.get_logs()"
|
||||
]
|
||||
|
@ -669,8 +518,7 @@
|
|||
"metadata": {},
|
||||
"source": [
|
||||
"Azure Machine Learning Studio にて正常に登録されていることを確認します。<br>\n",
|
||||
"<img src=\"../docs/images/azureml-deployment1.png\" width=500><br>\n",
|
||||
"\n"
|
||||
"<img src=\"docs/images/azureml-deployment1.png\" width=500><br>\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -697,7 +545,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649082311275
|
||||
|
@ -730,7 +578,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649082311281
|
||||
|
@ -747,21 +595,13 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"gather": {
|
||||
"logged": 1649082311289
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"b'[[0.7252904642292589, 0.2747095357707411]]'\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"try:\n",
|
||||
" response = urllib.request.urlopen(req)\n",
|
||||
|
|
После Ширина: | Высота: | Размер: 96 KiB |
После Ширина: | Высота: | Размер: 4.8 MiB |
После Ширина: | Высота: | Размер: 146 KiB |
После Ширина: | Высота: | Размер: 136 KiB |
После Ширина: | Высота: | Размер: 147 KiB |
После Ширина: | Высота: | Размер: 3.7 MiB |
После Ширина: | Высота: | Размер: 130 KiB |
После Ширина: | Высота: | Размер: 1.1 MiB |
|
@ -5,7 +5,7 @@
|
|||
"metadata": {},
|
||||
"source": [
|
||||
"# Azure Machine Learning による機械学習プロセス - モデル学習編\n",
|
||||
"本ノートブックでは、オープンソースライブラリの LightGBM (Python API) を用いてモデル学習を行っていきます。各機械学習プロセスを Azure Machine Learning Studio and/or Azure Machine Learning Python SDK を用いて管理します。"
|
||||
"本ノートブックでは、オープンソースライブラリの LightGBM (Python API) を用いたモデルを構築します。各機械学習プロセスを Azure Machine Learning Python SDK を用いて実行します。"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -144,8 +144,7 @@
|
|||
"metadata": {},
|
||||
"source": [
|
||||
"Azure Machine Learning Studio にて正常に登録されていることを確認します。<br>\n",
|
||||
"<img src=\"../docs/images/azureml-dataset4.png\" width=900><br>\n",
|
||||
"\n"
|
||||
"<img src=\"docs/images/azureml-dataset4.png\" width=900><br>"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -194,7 +193,7 @@
|
|||
"metadata": {},
|
||||
"source": [
|
||||
"Azure Machine Learning Studio にて正常に登録されていることを確認します。<br>\n",
|
||||
"<img src=\"../docs/images/azureml-environment2.png\" width=500><br>"
|
||||
"<img src=\"docs/images/azureml-environment2.png\" width=500><br>"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -275,8 +274,7 @@
|
|||
"metadata": {},
|
||||
"source": [
|
||||
"Azure Machine Learning Studio にて正常に登録されていることを確認します。<br>\n",
|
||||
"<img src=\"../docs/images/azureml-computeclusters4.png\" width=500><br>\n",
|
||||
"\n"
|
||||
"<img src=\"docs/images/azureml-computeclusters4.png\" width=500><br>"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -417,9 +415,9 @@
|
|||
"metadata": {},
|
||||
"source": [
|
||||
"Azure Machine Learning Studio にて正常にジョブが実行されたことを確認します。<br>\n",
|
||||
"<img src=\"../docs/images/azureml-experiment1.png\" width=500><br>\n",
|
||||
"<img src=\"docs/images/azureml-experiment1.png\" width=500><br>\n",
|
||||
"実行時間、メトリック、コードなどの情報が確認できます。<br>\n",
|
||||
"<img src=\"../docs/images/azureml-experiment2.png\" width=1500><br>\n"
|
||||
"<img src=\"docs/images/azureml-experiment2.png\" width=1500><br>\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -463,7 +461,7 @@
|
|||
"metadata": {},
|
||||
"source": [
|
||||
"Azure Machine Learning Studio にて正常に登録されていることを確認します。<br>\n",
|
||||
"<img src=\"../docs/images/azureml-model2.png\" width=500><br>"
|
||||
"<img src=\"docs/images/azureml-model2.png\" width=500><br>"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -477,7 +475,7 @@
|
|||
"kernelspec": {
|
||||
"display_name": "Python 3.8 - AzureML",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
"name": "python38-azureml"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
|
|