Creating the monitoring model

We create a new model by using the create method. Where we can define things like how the data should be chunked, the key performance metric, etc.

# Create model
model = nml_sdk.monitoring.Model.create(
    name='Example model',
    schema=schema,
    chunk_period='MONTHLY',
    reference_data=reference_data,
    analysis_data=analysis_data,
    target_data=target_data,
    key_performance_metric='F1',
)

More info about the Model class can be found in its API reference.

In case you are wondering why we need to pass the reference_data twice —once in the schema and another in the model created— the reason is that both steps are treated differently. In the schema inspection step, we transmit only a few rows (100 to be precise) to the NannyML Cloud server for deriving the schema. While when creating the model, the entire thing is uploaded, so that will take a bit more time.