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  | 
|---|---|
 object  | Required.   | 
 string  | Optional. The name of the custom model.  | 
 string  | Optional. The release version of the custom model.  | 
 list of string  | Optional. A list of strings denoting the feature name(s).  | 
 list of string  | Optional. A list of strings denoting the label name(s).  | 
 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