mlflow (version 1.9.0)

mlflow_param: Read Command-Line Parameter

Description

Reads a command-line parameter passed to an MLflow project MLflow allows you to define named, typed input parameters to your R scripts via the mlflow_param API. This is useful for experimentation, e.g. tracking multiple invocations of the same script with different parameters.

Usage

mlflow_param(name, default = NULL, type = NULL, description = NULL)

Arguments

name

The name of the parameter.

default

The default value of the parameter.

type

Type of this parameter. Required if `default` is not set. If specified, must be one of "numeric", "integer", or "string".

description

Optional description for the parameter.

Examples

Run this code
# 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)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab