azure-ai-mlmonitoring


Nameazure-ai-mlmonitoring JSON
Version 0.1.0a2 PyPI version JSON
download
home_page
SummaryAzure Machine Learning Model Monitoring SDK V2
upload_time2023-01-16 09:53:16
maintainer
docs_urlNone
authorMicrosoft Corporation
requires_python
licenseMIT License
keywords azuremachinelearning modelmonitoring
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Azure Machine Learning Model Monitoring SDK

The `azure-ai-mlmonitoring` package provides an SDK to enable Model Data Collector (MDC) for custom logging allows customers to collect data at arbitrary points in their data pre-processing pipeline. Customers can leverage SDK in `score.py` to log data to desired sink before, during, and after any data transformations. 

Start by importing the `azure-ai-mlmonitoring` package in `score.py`

```
import pandas as pd
import json
from azure.ai.mlmonitoring import Collector

def init():
  global inputs_collector, outputs_collector

  # instantiate collectors with appropriate names, make sure align with deployment spec
  inputs_collector = Collector(name='model_inputs')                    
  outputs_collector = Collector(name='model_outputs')

def run(data): 
  # convert json to python object and convert to pandas Dataframe
  input_df = pd.DataFrame(json.loads(data))

  # collect inputs data, store correlation_context
  context = inputs_collector.collect(input_df) 

  # perform scoring with pandas Dataframe, return value is also pandas Dataframe
  output_df = predict(input_df) 

  # collect outputs data, pass in correlation_context so inputs and outputs data can be correlated later
  outputs_collector.collect(output_df, context)
  
  return output_df.to_dict()
  
def predict(input_df):
  # process input and return with outputs
  ...
  
  return output_df
```

Create environment with base image `mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04` and conda dependencies, then build the environment.

```
channels:
  - conda-forge
dependencies:
  - python=3.8
  - numpy=1.23.5
  - pandas=1.5.2
  - pip=22.3.1
  - pip:
      - azureml-defaults==1.38.0
      - requests==2.28.1
      - azure-ai-mlmonitoring
name: model-env
```

Create deployment with custom logging enabled (model_inputs and model_outputs are enabled) and the environment you just built, please update the yaml according to your scenario.

```
#source ../configs/model-data-collector/data-storage-basic-OnlineDeployment.YAML
$schema: http://azureml/sdk-2-0/OnlineDeployment.json

endpoint_name: my_endpoint #unchanged
name: blue #unchanged
model: azureml:my-model-m1:1 #azureml:models/<name>:<version> #unchanged
environment: azureml:custom-logging-env:1 #unchanged
data_collector:
  model_inputs:
      enabled: true
  model_outputs:
      enabled: true
```

# Change Log

## [v0.1.0a2](https://pypi.org/project/azure-ai-mlmonitoring/0.1.0a2/) (2023.1.16)

**Improvements**

- Refine README.md.

## [v0.1.0a1](https://pypi.org/project/azure-ai-mlmonitoring/0.1.0a1/) (2023.1.4)

**New Features**

- Support model data collection for pandas Dataframe.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "azure-ai-mlmonitoring",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "AzureMachineLearning,ModelMonitoring",
    "author": "Microsoft Corporation",
    "author_email": "azuremlsdk@microsoft.com",
    "download_url": "",
    "platform": "any",
    "description": "# Azure Machine Learning Model Monitoring SDK\n\nThe `azure-ai-mlmonitoring` package provides an SDK to enable Model Data Collector (MDC) for custom logging allows customers to collect data at arbitrary points in their data pre-processing pipeline. Customers can leverage SDK in `score.py` to log data to desired sink before, during, and after any data transformations. \n\nStart by importing the `azure-ai-mlmonitoring` package in `score.py`\n\n```\nimport pandas as pd\nimport json\nfrom azure.ai.mlmonitoring import Collector\n\ndef init():\n  global inputs_collector, outputs_collector\n\n  # instantiate collectors with appropriate names, make sure align with deployment spec\n  inputs_collector = Collector(name='model_inputs')                    \n  outputs_collector = Collector(name='model_outputs')\n\ndef run(data): \n  # convert json to python object and convert to pandas Dataframe\n  input_df = pd.DataFrame(json.loads(data))\n\n  # collect inputs data, store correlation_context\n  context = inputs_collector.collect(input_df) \n\n  # perform scoring with pandas Dataframe, return value is also pandas Dataframe\n  output_df = predict(input_df) \n\n  # collect outputs data, pass in correlation_context so inputs and outputs data can be correlated later\n  outputs_collector.collect(output_df, context)\n  \n  return output_df.to_dict()\n  \ndef predict(input_df):\n  # process input and return with outputs\n  ...\n  \n  return output_df\n```\n\nCreate environment with base image `mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04` and conda dependencies, then build the environment.\n\n```\nchannels:\n  - conda-forge\ndependencies:\n  - python=3.8\n  - numpy=1.23.5\n  - pandas=1.5.2\n  - pip=22.3.1\n  - pip:\n      - azureml-defaults==1.38.0\n      - requests==2.28.1\n      - azure-ai-mlmonitoring\nname: model-env\n```\n\nCreate deployment with custom logging enabled (model_inputs and model_outputs are enabled) and the environment you just built, please update the yaml according to your scenario.\n\n```\n#source ../configs/model-data-collector/data-storage-basic-OnlineDeployment.YAML\n$schema: http://azureml/sdk-2-0/OnlineDeployment.json\n\nendpoint_name: my_endpoint #unchanged\nname: blue #unchanged\nmodel: azureml:my-model-m1:1 #azureml:models/<name>:<version> #unchanged\nenvironment: azureml:custom-logging-env:1 #unchanged\ndata_collector:\n  model_inputs:\n      enabled: true\n  model_outputs:\n      enabled: true\n```\n\n# Change Log\n\n## [v0.1.0a2](https://pypi.org/project/azure-ai-mlmonitoring/0.1.0a2/) (2023.1.16)\n\n**Improvements**\n\n- Refine README.md.\n\n## [v0.1.0a1](https://pypi.org/project/azure-ai-mlmonitoring/0.1.0a1/) (2023.1.4)\n\n**New Features**\n\n- Support model data collection for pandas Dataframe.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Azure Machine Learning Model Monitoring SDK V2",
    "version": "0.1.0a2",
    "split_keywords": [
        "azuremachinelearning",
        "modelmonitoring"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ecccfea2445a79bf5dc2fe071127cfe9fd1e463d1d842e4854e6734f8b2b215f",
                "md5": "e19ace31941b70be593559d1b9e47068",
                "sha256": "52aa541b66827d67a572b12b384b95fe998868dc1f7e14fda930d4dcbdd74402"
            },
            "downloads": -1,
            "filename": "azure_ai_mlmonitoring-0.1.0a2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e19ace31941b70be593559d1b9e47068",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17471,
            "upload_time": "2023-01-16T09:53:16",
            "upload_time_iso_8601": "2023-01-16T09:53:16.997859Z",
            "url": "https://files.pythonhosted.org/packages/ec/cc/fea2445a79bf5dc2fe071127cfe9fd1e463d1d842e4854e6734f8b2b215f/azure_ai_mlmonitoring-0.1.0a2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-16 09:53:16",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "azure-ai-mlmonitoring"
}
        
Elapsed time: 0.04896s