Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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:
  collections:
    model_inputs:
      enabled: true
    model_outputs:
      enabled: true

Change Log

v0.1.0a3 (2023.2.13)

Improvements

  • Refine README.md.
  • Refactor code.
  • Log error message when data collected is not Pandas Dataframe.

v0.1.0a2 (2023.1.16)

Improvements

  • Refine README.md.

v0.1.0a1 (2023.1.4)

New Features

  • Support model data collection for pandas Dataframe.

Metadata

Release files for azure-ai-mlmonitoring 0.1.0a3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for azure-ai-mlmonitoring 0.1.0a3
File Interpreter ABI Platform
azure_ai_mlmonitoring-0.1.0a3-py3-none-any.whl Python 3 none any Details

Release files / azure_ai_mlmonitoring-0.1.0a3-py3-none-any.whl

Download URL azure_ai_mlmonitoring-0.1.0a3-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cda737f3e1ec5f7c953dd024023c5ae0b3ef3bdeb27b0a56f04b4d55f79bf906
BLAKE2b-256 checksum
How to use checksums
1e8350853708d179f1b213853a740f574350f9d5eb0eee7c9e0d810c89bac679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.16

Security for azure-ai-mlmonitoring 0.1.0a3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page