• EnglishEspañol日本語한국어Português
  • Log inStart now

wrap_mlmodel (Python agent API)

Syntax

newrelic.agent.wrap_mlmodel(model, name=None, version=None, feature_names=None, label_names=None, metadata=None)

Enables manual instrumentation of machine learning models.

Requirements

Python agent version 9.1.0 or higher.

Description

This allows for manual instrumentation of machine learning models.

Parameters

Parameter

Description

model

object

Required. model is the fitted machine learning model.

name

string

Optional. The name of the custom model.

version

string

Optional. The release version of the custom model.

feature_names

list of string

Optional. A list of strings denoting the feature name(s).

label_names

list of string

Optional. A list of strings denoting the label name(s).

metadata

dict

Optional. Metadata to attach to the model.

Return values

None.

Examples

Wrap machine learning model

An example of instrumenting a custom machine learning model:

def wrap_ml_example():
x_train = [[0, 0], [1, 1]]
y_train = [0, 1]
x_test = [[1.0, 2.0]]
model = CustomTestModel().fit(x_train, y_train)
wrap_mlmodel(
model,
name="MyCustomModel",
version="1.2.3",
feature=["feature0", "feature1"],
label=["label0"],
metadata={"metadata1": "value1", "metadata2": "value2"},
)
labels = model.predict(x_test)
return model
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.