e ZenML CLI to install the right version directly.The zenml integration install sklearn command is simply doing a pip install of sklearn behind the scenes. If something goes wrong, one can always use zenml integration requirements sklearn to see which requirements are compatible and install using pip (or any other tool) directly. (If no specific requirements are mentioned for an integration then this means we support using all possible versions of that integration/package.)

Define a data loader with multiple outputs

A typical start of an ML pipeline is usually loading data from some source. This step will sometimes have multiple outputs. To define such a step, use a Tuple type annotation. Additionally, you can use the Annotated annotation to assign custom output names. Here we load an open-source dataset and split it into a train and a test dataset.

import logging

@step

def training_data_loader() -> Tuple[

# Notice we use a Tuple and Annotated to return

# multiple named outputs

Annotated[pd.DataFrame, "X_train"],

Annotated[pd.DataFrame, "X_test"],

Annotated[pd.Series, "y_train"],

Annotated[pd.Series, "y_test"],

]:

"""Load the iris dataset as a tuple of Pandas DataFrame / Series."""

logging.info("Loading iris...")

iris = load_iris(as_frame=True)

logging.info("Splitting train and test...")

X_train, X_test, y_train, y_test = train_test_split(

iris.data, iris.target, test_size=0.2, shuffle=True, random_state=42

return X_train, X_test, y_train, y_test

ZenML records the root python logging handler's output into the artifact store as a side-effect of running a step. Therefore, when writing steps, use the logging module to record logs, to ensure that these logs then show up in the ZenML dashboard.

Create a parameterized training step

Here we are creating a training step for a support vector machine classifier with sklearn. As we might want to adjust the hyperparameter gamma later on, we define it as an input value to the step as well.

@step

def svc_trainer(

X_train: pd.DataFrame,