Model: Artifacts, Package, Surrogate
Last updated
Was this helpful?
Last updated
Was this helpful?
A model in Fiddler is a placeholder that may not need the model artifacts for monitoring purposes. However, for explainability, model artifacts are needed.
Required model artifacts include:
The (e.g. *.pkl
)
: A wrapper script containing all of the code needed to standardize the execution of the model.
A collection of model artifacts in a directory is referred to as a model package. To start, place your model artifacts in a new directory. This directory will be the model package you will upload to Fiddler to add or update model artifacts.
While the model file and package.py are required artifacts in a model package, you can also optionally add other artifacts such as any serialized needed to transform data before running predictions or after.
In the following, we discuss the various model artifacts.
A model file is a serialized representation of your model as a Python object.
Model files can be stored in a variety of formats. Some include
Pickle (.pkl
)
Protocol buffer (.pb
)
Hierarchical Data Format/HDF5 (.h5
)
Fiddlerβs artifact upload process is framework-agnostic. Because of this, a wrapper script is needed to let Fiddler know how to interact with your particular model and framework.
The wrapper script should be named package.py
, and it should be placed in the same directory as your model artifact. Below is an example of what package.py
should look like.
The only hard requirements for package.py
are
The script must be named package.py
The script must implement a function called get_model
, which returns a model object
This model object must implement a function called predict
, which takes in a pandas DataFrame of model inputs and returns a pandas DataFrame of model predictions
Another component of your model package could be any serialized preprocessing objects that are used to transform the data before or after making predictions.
You can place these in the model package directory as well.
π Info
For example, in the case that we have a categorical feature, we may need to encode it as one or more numeric columns before calling the modelβs prediction function. In that case, we may have a serialized transform object called
encoder.pkl
. This should also be included in the model package directory.
π Info
This is only used starting at 23.1 version with Model Deployment enabled.
Add the dependencies to requirements.txt file like this:
A surrogate model is an approximation of your model intended to make qualitative explainability calculations possible for scenarios where model ingestion is impossible or explainability is an occasional nice-to-have, but not a primary component of a model monitoring workflow.
π§ Surrogates can currently only be created for models with tabular input types.
Fiddler produces a surrogate by training a gradient-boosted decision tree (LightGBM) to the ground-truth labels provided and with a general, predefined set of settings.
Each base image (see for more information on base images) comes with a few pre-installed libraries and these can be overridden by specifying requirements.txt
file inside your model artifact directory where package.py
is defined.
Fiddler creates a surrogate when you call . This requires that you've already added a model using .
If your model artifact requires specific packages to run, Fiddler can support this with the Flexible Model Deployment feature. See for details on how to configure your model with the correct requirements.
Questions? to a product expert or a demo.
Need help? Contact us at .