Edit on GitHub


Load Python object saved by MLEM

def load(
    path: str,
    project: Optional[str] = None,
    rev: Optional[str] = None,
    batch_size: Optional[int] = None,
    follow_links: bool = True,
) -> Any


import os
from mlem.api import load

out_path = os.path.join(os.getcwd(), "saved-model")
loaded = load(out_path)


Loads a Python object from a given path. The path can belong to different file systems (eg: S3). The function returns the underlying Python object saved by MLEM.


  • path (required) - Path to the object. Could be local path or path inside a Git repo.
  • project (optional) - URL to project if object is located there.
  • rev (optional) - revision, could be Git commit SHA, branch name or tag.
  • follow_links (optional) - If object we read is a MLEM link, whether to load the actual object link points to. Defaults to True.



Example: Load a trained model saved with MLEM

import os
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from mlem.api import load

path = os.path.join(os.getcwd(), "saved-model")

model = load(path)
assert isinstance(model, DecisionTreeClassifier)
train, _ = load_iris(return_X_y=True)

­čÉŤ Found an issue? Let us know! Or fix it:

Edit on GitHub

ÔŁô Have a question? Join our chat, we will help you:

Discord Chat