Skip to content

Commit

Permalink
Added new files due to change in Azure udacity account
Browse files Browse the repository at this point in the history
  • Loading branch information
RohitRanga12 committed Sep 19, 2022
1 parent 92d0bb0 commit 475adb3
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 15 deletions.
55 changes: 51 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,65 @@
*NOTE:* This file is a template that you can use to create the README for your project. The *TODO* comments below will highlight the information you should be sure to include.


# Your Project Title Here
# Project Title: Operationalizing Machine Learning

Project Overview:
- Dataset used: Bank Marketing dataset.
- I use Azure to configure a cloud-based ML production model, deploy it, and consume it.
- I create, publish, and consume a pipeline.
- I demonstrate all my work by creating a README file and a screencast video.

*TODO:* Write an overview to your project.

## Architectural Diagram
*TODO*: Provide an architectual diagram of the project and give an introduction of each step. An architectural diagram is an image that helps visualize the flow of operations from start to finish. In this case, it has to be related to the completed project, with its various stages that are critical to the overall flow. For example, one stage for managing models could be "using Automated ML to determine the best model".

## Key Steps
*TODO*: Write a short discription of the key steps. Remeber to include all the screenshots required to demonstrate key steps.
*TODO*: include all the screenshots
Step 1: Authentication
- I skipped this step since I used Udacity Lab and thus could not create a Service Principal

Step 2: Auto ML Experiment
- Upload data (csv file) to default datastore in Azure ML studio, and register a dataset
- Create a compute instance to be used by the jupyter notebook later
- Create a compute cluster to be used by the AutoML experiment with min nodes as 1, and max nodes as 5
- Create an AutoML experiment with the above dataset and compute cluster
<img src="screenshots/registered_dataset.png">
<img src="screenshots/experiment_completed.png">
<img src="screenshots/best_model_voting_ensemble.png">

Step 3: Deploy Best Model
- Once AutoML experiment completes, deploy the best model on ACI with authentication enabled

Step 4: Enable Logging
- Create a python virtual/conda environment with libraries required to run the scripts. Activate it.
- Download config.json from Azure ML portal and store in same folder as logs.py
- In logs.py, insert the deployment name. From terminal, run "python logs.py" to enable logging
<img src="screenshots/app_insights_enabled.png">
<img src="screenshots/logs_screenshot.png">

Step 5: Swagger Documentation
- Copy the swagger.json URL from the deployment, use wget to download file inside 'swagger' folder
- From /swagger directory, run "bash swagger.sh" to launch docker in localhost port 10000. You can view swagger UI in localhost:10000.
- Run "python serve.py", and insert "http://localhost:8000/swagger.json" in the search bar in Swagger UI. This will show the /score endpoint
<img src="screenshots/swagger_http_endpoints_localhost.png">

Step 6: Consume Model Endpoint
- In endpoint.py, insert the scoring_uri and key from the deployment, and run "python endpoint.py"
- Benchmark endpoint: Check if Apache Benchmark is installed. In benchmark.sh, insert appropriate key and scoring_uri and run "bash benchmark.sh"
<img src="screenshots/endpoint_script_json_output.png">
<img src="screenshots/benchmark_results.png">

Step 7: Create, Publish, Consume Pipeline
- Run the cells in the aml-pipelines-with-automated-machine-learning-step.ipynb notebook after inserting the right cluster name, experiment name, dataset name. This would create and publish pipeline.
<img src="screenshots/pipeline_created.png">
<img src="screenshots/pipeline_endpoint.png">
<img src="screenshots/bank_dataset_with_automl_module.png">
<img src="screenshots/published_pipeline_overview_status_active.png">
<img src="screenshots/run_details_widget_step_runs.png">


## Screen Recording
*TODO* Provide a link to a screen recording of the project in action. Remember that the screencast should demonstrate:

## Standout Suggestions
*TODO (Optional):* This is where you can provide information about any standout suggestions that you have attempted.
- Performed the Model Endpoint's benchmarking using Apache Benchmark (though it was optional)
11 changes: 8 additions & 3 deletions aml-pipelines-with-automated-machine-learning-step.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@
"name": "python3"
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.8.9 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -638,7 +638,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1"
"version": "3.8.9"
},
"nteract": {
"version": "nteract-front-end@1.0.0"
Expand All @@ -650,7 +650,12 @@
"tags": [
"None"
],
"task": "Demonstrates the use of AutoMLStep"
"task": "Demonstrates the use of AutoMLStep",
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
2 changes: 1 addition & 1 deletion benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
# Total: 114 160 28.0 172 199#


ab -n 10 -v 4 -p data.json -T 'application/json' -H 'Authorization: Bearer MUaeLF7LnpSl9yDcG1oDcKDxTbj3GFdU' http://1720786b-dce4-4c95-9d81-97e0cefe98a1.southcentralus.azurecontainer.io/score
ab -n 10 -v 4 -p data.json -T 'application/json' -H 'Authorization: Bearer 8AhR2Mbj41zndK9gWggipcFXscClb2qQ' http://915c9d86-81d0-48b5-9e00-8af405f959ba.southcentralus.azurecontainer.io/score
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"subscription_id": "3e42d11f-d64d-4173-af9b-12ecaa1030b3",
"resource_group": "aml-quickstarts-207494",
"workspace_name": "quick-starts-ws-207494"
"subscription_id": "48a74bb7-9950-4cc1-9caa-5d50f995cc55",
"resource_group": "aml-quickstarts-207816",
"workspace_name": "quick-starts-ws-207816"
}
4 changes: 2 additions & 2 deletions endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

# URL for the web service, should be similar to:
# 'http://8530a665-66f3-49c8-a953-b82a2d312917.eastus.azurecontainer.io/score'
scoring_uri = 'http://1720786b-dce4-4c95-9d81-97e0cefe98a1.southcentralus.azurecontainer.io/score'
scoring_uri = 'http://915c9d86-81d0-48b5-9e00-8af405f959ba.southcentralus.azurecontainer.io/score'

# If the service is authenticated, set the key or token
key = 'MUaeLF7LnpSl9yDcG1oDcKDxTbj3GFdU'
key = '8AhR2Mbj41zndK9gWggipcFXscClb2qQ'

# Two sets of data to score, so we get two results back
data = {
Expand Down
2 changes: 1 addition & 1 deletion logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ws = Workspace.from_config()

# Set with the deployment name
name = "best-bankmarketing-model"
name = "best-mlops-model"

# load existing web service
service = Webservice(name=name, workspace=ws)
Expand Down
Binary file added screenshots/bank_dataset_with_automl_module.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/pipeline_created.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/pipeline_endpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/run_details_widget_step_runs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion swagger/swagger.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"swagger": "2.0", "info": {"title": "best-bankmarketing-model", "description": "API specification for the Azure Machine Learning service best-bankmarketing-model", "version": "1.0"}, "schemes": ["https"], "consumes": ["application/json"], "produces": ["application/json"], "securityDefinitions": {"Bearer": {"type": "apiKey", "name": "Authorization", "in": "header", "description": "For example: Bearer abc123"}}, "paths": {"/": {"get": {"operationId": "ServiceHealthCheck", "description": "Simple health check endpoint to ensure the service is up at any given point.", "responses": {"200": {"description": "If service is up and running, this response will be returned with the content 'Healthy'", "schema": {"type": "string"}, "examples": {"application/json": "Healthy"}}, "default": {"description": "The service failed to execute due to an error.", "schema": {"$ref": "#/definitions/ErrorResponse"}}}}}, "/score": {"post": {"operationId": "RunMLService", "description": "Run web service's model and get the prediction output", "security": [{"Bearer": []}], "parameters": [{"name": "serviceInputPayload", "in": "body", "description": "The input payload for executing the real-time machine learning service.", "schema": {"$ref": "#/definitions/ServiceInput"}}], "responses": {"200": {"description": "The service processed the input correctly and provided a result prediction, if applicable.", "schema": {"$ref": "#/definitions/ServiceOutput"}}, "default": {"description": "The service failed to execute due to an error.", "schema": {"$ref": "#/definitions/ErrorResponse"}}}}}, "/swagger.json": {"get": {"operationId": "GetSwaggerSpec", "description": "Get the Swagger specification.", "parameters": [{"name": "version", "in": "query", "required": false, "type": "integer", "enum": [2, 3]}], "responses": {"200": {"description": "The Swagger specification.", "schema": {"type": "string"}}, "default": {"description": "The service failed to execute due to an error.", "schema": {"$ref": "#/definitions/ErrorResponse"}}}}}}, "definitions": {"ServiceInput": {"type": "object", "properties": {"Inputs": {"type": "object", "required": ["data"], "properties": {"data": {"type": "array", "items": {"type": "object", "required": ["age", "job", "marital", "education", "default", "housing", "loan", "contact", "month", "day_of_week", "duration", "campaign", "pdays", "previous", "poutcome", "emp.var.rate", "cons.price.idx", "cons.conf.idx", "euribor3m", "nr.employed"], "properties": {"age": {"type": "integer", "format": "int64"}, "job": {"type": "string"}, "marital": {"type": "string"}, "education": {"type": "string"}, "default": {"type": "string"}, "housing": {"type": "string"}, "loan": {"type": "string"}, "contact": {"type": "string"}, "month": {"type": "string"}, "day_of_week": {"type": "string"}, "duration": {"type": "integer", "format": "int64"}, "campaign": {"type": "integer", "format": "int64"}, "pdays": {"type": "integer", "format": "int64"}, "previous": {"type": "integer", "format": "int64"}, "poutcome": {"type": "string"}, "emp.var.rate": {"type": "number", "format": "double"}, "cons.price.idx": {"type": "number", "format": "double"}, "cons.conf.idx": {"type": "number", "format": "double"}, "euribor3m": {"type": "number", "format": "double"}, "nr.employed": {"type": "number", "format": "double"}}}, "format": "pandas.DataFrame:records"}}}, "GlobalParameters": {"type": "object", "required": ["method"], "properties": {"method": {"type": "string"}}}}, "example": {"Inputs": {"data": [{"age": 0, "job": "example_value", "marital": "example_value", "education": "example_value", "default": "example_value", "housing": "example_value", "loan": "example_value", "contact": "example_value", "month": "example_value", "day_of_week": "example_value", "duration": 0, "campaign": 0, "pdays": 0, "previous": 0, "poutcome": "example_value", "emp.var.rate": 0.0, "cons.price.idx": 0.0, "cons.conf.idx": 0.0, "euribor3m": 0.0, "nr.employed": 0.0}]}, "GlobalParameters": {"method": "predict"}}}, "ServiceOutput": {"type": "object", "required": ["Results"], "properties": {"Results": {"type": "array", "items": {"type": "string"}, "format": "numpy.ndarray"}}, "example": {"Results": ["example_value"]}}, "ErrorResponse": {"type": "object", "properties": {"status_code": {"type": "integer", "format": "int32"}, "message": {"type": "string"}}}}}
{"swagger": "2.0", "info": {"title": "best-mlops-model", "description": "API specification for the Azure Machine Learning service best-mlops-model", "version": "1.0"}, "schemes": ["https"], "consumes": ["application/json"], "produces": ["application/json"], "securityDefinitions": {"Bearer": {"type": "apiKey", "name": "Authorization", "in": "header", "description": "For example: Bearer abc123"}}, "paths": {"/": {"get": {"operationId": "ServiceHealthCheck", "description": "Simple health check endpoint to ensure the service is up at any given point.", "responses": {"200": {"description": "If service is up and running, this response will be returned with the content 'Healthy'", "schema": {"type": "string"}, "examples": {"application/json": "Healthy"}}, "default": {"description": "The service failed to execute due to an error.", "schema": {"$ref": "#/definitions/ErrorResponse"}}}}}, "/score": {"post": {"operationId": "RunMLService", "description": "Run web service's model and get the prediction output", "security": [{"Bearer": []}], "parameters": [{"name": "serviceInputPayload", "in": "body", "description": "The input payload for executing the real-time machine learning service.", "schema": {"$ref": "#/definitions/ServiceInput"}}], "responses": {"200": {"description": "The service processed the input correctly and provided a result prediction, if applicable.", "schema": {"$ref": "#/definitions/ServiceOutput"}}, "default": {"description": "The service failed to execute due to an error.", "schema": {"$ref": "#/definitions/ErrorResponse"}}}}}, "/swagger.json": {"get": {"operationId": "GetSwaggerSpec", "description": "Get the Swagger specification.", "parameters": [{"name": "version", "in": "query", "required": false, "type": "integer", "enum": [2, 3]}], "responses": {"200": {"description": "The Swagger specification.", "schema": {"type": "string"}}, "default": {"description": "The service failed to execute due to an error.", "schema": {"$ref": "#/definitions/ErrorResponse"}}}}}}, "definitions": {"ServiceInput": {"type": "object", "properties": {"Inputs": {"type": "object", "required": ["data"], "properties": {"data": {"type": "array", "items": {"type": "object", "required": ["age", "job", "marital", "education", "default", "housing", "loan", "contact", "month", "day_of_week", "duration", "campaign", "pdays", "previous", "poutcome", "emp.var.rate", "cons.price.idx", "cons.conf.idx", "euribor3m", "nr.employed"], "properties": {"age": {"type": "integer", "format": "int64"}, "job": {"type": "string"}, "marital": {"type": "string"}, "education": {"type": "string"}, "default": {"type": "string"}, "housing": {"type": "string"}, "loan": {"type": "string"}, "contact": {"type": "string"}, "month": {"type": "string"}, "day_of_week": {"type": "string"}, "duration": {"type": "integer", "format": "int64"}, "campaign": {"type": "integer", "format": "int64"}, "pdays": {"type": "integer", "format": "int64"}, "previous": {"type": "integer", "format": "int64"}, "poutcome": {"type": "string"}, "emp.var.rate": {"type": "number", "format": "double"}, "cons.price.idx": {"type": "number", "format": "double"}, "cons.conf.idx": {"type": "number", "format": "double"}, "euribor3m": {"type": "number", "format": "double"}, "nr.employed": {"type": "number", "format": "double"}}}, "format": "pandas.DataFrame:records"}}}, "GlobalParameters": {"type": "object", "required": ["method"], "properties": {"method": {"type": "string"}}}}, "example": {"Inputs": {"data": [{"age": 0, "job": "example_value", "marital": "example_value", "education": "example_value", "default": "example_value", "housing": "example_value", "loan": "example_value", "contact": "example_value", "month": "example_value", "day_of_week": "example_value", "duration": 0, "campaign": 0, "pdays": 0, "previous": 0, "poutcome": "example_value", "emp.var.rate": 0.0, "cons.price.idx": 0.0, "cons.conf.idx": 0.0, "euribor3m": 0.0, "nr.employed": 0.0}]}, "GlobalParameters": {"method": "predict"}}}, "ServiceOutput": {"type": "object", "required": ["Results"], "properties": {"Results": {"type": "array", "items": {"type": "string"}, "format": "numpy.ndarray"}}, "example": {"Results": ["example_value"]}}, "ErrorResponse": {"type": "object", "properties": {"status_code": {"type": "integer", "format": "int32"}, "message": {"type": "string"}}}}}

0 comments on commit 475adb3

Please sign in to comment.