mlflow_param: Read Command-Line Parameter

Description Usage Arguments Examples

View source: R/project-param.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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 Sept. 6, 2021, 9:06 a.m.