mlflow_run: Run an MLflow Project

View source: R/project-run.R

mlflow_runR Documentation

Run an MLflow Project

Description

Wrapper for the 'mlflow run' CLI command. See https://www.mlflow.org/docs/latest/cli.html#mlflow-run for more info.

Usage

mlflow_run(
  uri = ".",
  entry_point = NULL,
  version = NULL,
  parameters = NULL,
  experiment_id = NULL,
  experiment_name = NULL,
  backend = NULL,
  backend_config = NULL,
  env_manager = NULL,
  storage_dir = NULL
)

Arguments

uri

A directory containing modeling scripts, defaults to the current directory.

entry_point

Entry point within project, defaults to 'main' if not specified.

version

Version of the project to run, as a Git commit reference for Git projects.

parameters

A list of parameters.

experiment_id

ID of the experiment under which to launch the run.

experiment_name

Name of the experiment under which to launch the run.

backend

Execution backend to use for run.

backend_config

Path to JSON file which will be passed to the backend. For the Databricks backend, it should describe the cluster to use when launching a run on Databricks.

env_manager

If specified, create an environment for the project using the specified environment manager. Available options are 'local', 'virtualenv', and 'conda'.

storage_dir

Valid only when 'backend' is local. MLflow downloads artifacts from distributed URIs passed to parameters of type 'path' to subdirectories of 'storage_dir'.

Value

The run associated with this run.

Examples

## Not run: 
# This parametrized script trains a GBM model on the Iris dataset and can be run as an MLflow
# project. You can run this script (assuming it's saved at /some/directory/params_example.R)
# with custom parameters via:
# mlflow_run(entry_point = "params_example.R", uri = "/some/directory",
#   parameters = list(num_trees = 200, learning_rate = 0.1))
install.packages("gbm")
library(mlflow)
library(gbm)
# define and read input parameters
num_trees <- mlflow_param(name = "num_trees", default = 200, type = "integer")
lr <- mlflow_param(name = "learning_rate", default = 0.1, type = "numeric")
# use params to fit a model
ir.adaboost <- gbm(Species ~., data=iris, n.trees=num_trees, shrinkage=lr)

## End(Not run)



mlflow documentation built on Nov. 1, 2024, 1:07 a.m.