sasctl.pzmm.pickle_model#
- class sasctl.pzmm.pickle_model.PickleModel[source]#
Bases:
object
- classmethod pickle_trained_model(model_prefix: str, trained_model: Any | None = None, pickle_path: str | Path | None = None, is_h2o_model: bool = False, is_binary_model: bool = False, is_binary_string: bool = False, mlflow_details: dict | None = None) dict | str | None [source]#
Write trained model to a binary pickle file, H2O MOJO file, or a binary string object.
The following files are generated by this function:
- ‘*.pickle’
Binary pickle file containing a trained model.
- ‘*.mojo’
Archived H2O.ai MOJO file containing a trained model.
- Parameters:
model_prefix (str or pathlib.Path) – Variable name for the model to be displayed in SAS Open Model Manager (i.e. hmeqClassTree + [Score.py || .pickle]).
trained_model (Any) – The trained model to be exported.
pickle_path (str, optional) – File location for the output pickle file. The default value is None.
is_h2o_model (bool, optional) – Sets whether the model file is an H2O.ai MOJO file. If set as True, the MOJO file will be gzipped before uploading to SAS Model Manager. The default value is False.
is_binary_model (bool, optional) – Sets whether the H2O model provided is a binary model or a MOJO model. The default value is False.
is_binary_string (bool, optional) – Sets whether the model is to be set as a binary string instead of a pickle file. The default value is False.
mlflow_details (dict, optional) – Model details from an MLFlow model. This dictionary is created by the readMLModelFile function. The default value is None.
- Returns:
binary_string (str) – When the is_binary_string flag is set to True, return a binary string representation of the model instead of a pickle or MOJO file.
dict – Dictionary containing a key-value pair representing the file name and pickle dump respectively if pickle_path is None. This is not valid for H2O.ai models.