mlflow.recipes

MLflow Recipes is a framework that enables you to quickly develop high-quality models and deploy them to production. Compared to ad-hoc ML workflows, MLflow Recipes offers several major benefits:

  • Recipe templates: Predefined templates for common ML tasks, such as regression modeling, enable you to get started quickly and focus on building great models, eliminating the large amount of boilerplate code that is traditionally required to curate datasets, engineer features, train & tune models, and package models for production deployment.

  • Recipe engine: The intelligent recipe execution engine accelerates model development by caching results from each step of the process and re-running the minimal set of steps as changes are made.

  • Production-ready structure: The modular, git-integrated recipe structure dramatically simplifies the handoff from development to production by ensuring that all model code, data, and configurations are easily reviewable and deployable by ML engineers.

For more information, see the MLflow Recipes overview.

class mlflow.recipes.Recipe[source]

A factory class that creates an instance of a recipe for a particular ML problem (e.g. regression, classification) or MLOps task (e.g. batch scoring) based on the current working directory and supplied configuration.

Example
import os
from mlflow.recipes import Recipe

os.chdir("~/recipes-regression-template")
regression_recipe = Recipe(profile="local")
regression_recipe.run(step="train")
static __new__(cls, profile: str)[source]

Creates an instance of an MLflow Recipe for a particular ML problem or MLOps task based on the current working directory and supplied configuration. The current working directory must be the root directory of an MLflow Recipe repository or a subdirectory of an MLflow Recipe repository.

Parameters

profile – The name of the profile to use for configuring the problem-specific or task-specific recipe. Profiles customize the configuration of one or more recipe steps, and recipe executions with different profiles often produce different results.

Returns

A recipe for a particular ML problem or MLOps task. For example, an instance of RegressionRecipe for regression problems.

import os
from mlflow.recipes import Recipe

os.chdir("~/recipes-regression-template")
regression_recipe = Recipe(profile="local")
regression_recipe.run(step="train")
class mlflow.recipes.recipe.BaseRecipe[source]

Base Recipe

clean(step: Optional[str] = None)None[source]

Removes the outputs of the specified step from the cache, or removes the cached outputs of all steps if no particular step is specified. After cached outputs are cleaned for a particular step, the step will be re-executed in its entirety the next time it is invoked via BaseRecipe.run().

Parameters

step – String name of the step to clean within the recipe. If not specified, cached outputs are removed for all recipe steps.

get_artifact(artifact_name: str)[source]

Read an artifact from recipe output. artifact names can be obtained from Recipe.inspect() or Recipe.run() output.

Returns None if the specified artifact is not found. Raise an error if the artifact is not supported.

inspect(step: Optional[str] = None)None[source]

Displays main output from a step, or a recipe DAG if no step is specified.

Parameters

step – String name to display a step output within the recipe. If a step is not specified, the DAG of the recipe is shown instead.

Returns

None

property name

Returns the name of the recipe.

property profile

Returns the profile under which the recipe and its steps will execute.

run(step: Optional[str] = None)None[source]

Runs a step in the recipe, or the entire recipe if a step is not specified.

Parameters

step – String name to run a step within the recipe. The step and its dependencies will be run sequentially. If a step is not specified, the entire recipe is executed.

Returns

None