mlflow_param: Read Command-Line Parameter

View source: R/project-param.R

mlflow_paramR Documentation

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

## 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. 23, 2023, 9:13 a.m.