bslearn: Find the Optimal Boolean Rule for Binary Classification

View source: R/bsnsing.R

bslearnR Documentation

Find the Optimal Boolean Rule for Binary Classification

Description

The function solves a mixed integer program (MIP) to either maximize the Gini reduction (opt.model = 'gini') or the number of misclassifications (opt.model = 'error'). The optimal rule serves as the split condition in the classification tree built by bsnsing.

Usage

bslearn(bx, y, control = bscontrol())

Arguments

bx

a data frame with binary (0 and 1) entries.

y

an integer vector with binary entries.

control

an object of class bscontrol(), specifying the algorithmic parameters. The list should contain the following attributes: opt.model, a character string in 'gini','error' indicating the optimization model to solve, opt.solver, a character string in 'gurobi', 'cplex', 'lpSolve', 'enum', 'enum_c', 'greedy' indicating the optimization method or solver to be used.

Value

a list containing the splitting solution.

Examples

## Not run: 
x <- auto[, c('mpg', 'cylinders', 'displacement')]
y <- ifelse(auto$origin == 'USA', 1L, 0L)
# binarize x by y = 1
bx <- binarize(x, y, target = 1)
# learn the optimal Boolean rule
bssol <- bslearn(bx, y, bscontrol(opt.solver = 'enum'))
cat(paste("Optimal rule:" , bssol$rules, "\n"))

## End(Not run)

profyliu/bsnsing documentation built on July 5, 2022, 8:10 a.m.