rail.core.model module
Wrapper class for ML Models
- class rail.core.model.Model
Bases:
objectClass to act as wrapper for ML models
This will attach metadata to the ML model, and provide tools for validation, versioning and tracking provenance.
- __init__(data, creation_class_name, version=0, catalog_tag=None, provenance=None)
Constructor
- Parameters:
data (Any) – Model data
creation_class_name (str) – Name of class that created this model
version (int) – Version of the model
catalog_tag (str | None) – Associated CatalogConfigBase that defined training dataset
provenance (dict | None) – Provenance infomration
- Return type:
None
- classmethod dump(obj, path, creation_class_name='dummy', version=0, catalog_tag=None, provenance=None)
Write an object to a model file
This will promote it to a Model if it isn’t already
- Parameters:
obj (Any) – Object to dump
path (str) – File to write
creation_class_name (str) – Name of class that created this model
version (int) – Version of the model
catalog_tag (str | None) – Associated CatalogConfigBase that defined training dataset
provenance (dict | None) – Provenance information
- Returns:
Newly converted Model
- Return type:
- classmethod read(path, creation_class_name='dummy', version=0, catalog_tag=None, provenance=None)
Read a model from a file.
Note that this will promote the data to a Model if it is not already
- Parameters:
path (str) – File to read
creation_class_name (str) – Name of class that created this model
version (int) – Version of the model
catalog_tag (str | None) – Associated CatalogConfigBase that defined training dataset
provenance (dict | None) – Provenance infomration
- Returns:
Newly read Model
- Return type:
- validate(creation_class_name, version)
- Parameters:
creation_class_name (str | None) – Name of class that created this model
version (int | None) – Version of the model
- Return type:
None
:raises TypeError : Either creation_class_name or version does not match:
- classmethod wrap(inpath, outpath, creation_class_name='dummy', version=0, catalog_tag=None, provenance=None)
Read a model from a file and write it as a Model if it is not already
- Parameters:
inpath (str) – File to read
outpath (str) – File to write
creation_class_name (str) – Name of class that created this model
version (int) – Version of the model
catalog_tag (str | None) – Associated CatalogConfigBase that defined training dataset
provenance (dict | None) – Provenance information
- Returns:
Newly read & converted Model
- Return type:
- write(path)
Write a model to a file
- Parameters:
path (str) – File to write
- Return type:
None