create_monotone_constraints {autostats}R Documentation

create monotone constraints

Description

helper function to create the integer vector to pass to the monotone_constraints argument in xgboost

Usage

create_monotone_constraints(
  .data,
  formula,
  decreasing = NULL,
  increasing = NULL
)

Arguments

.data

dataframe, training data for tidy_xgboost

formula

formula used for tidy_xgboost

decreasing

character vector or tidyselect regular expression to designate decreasing cols

increasing

character vector or tidyselect regular expression to designate increasing cols

Value

a named integer vector with entries of 0, 1, -1

Examples




iris %>%
framecleaner::create_dummies(Species) -> iris_dummy

iris_dummy %>%
 tidy_formula(target= Petal.Length) -> petal_form

iris_dummy %>%
 create_monotone_constraints(petal_form,
                             decreasing = tidyselect::matches("Petal|Species"),
                             increasing = "Sepal.Width")


[Package autostats version 0.4.1 Index]