bslearn {bsnsing}R Documentation

Find the Optimal Boolean Rule for Binary Classification

Description

The function solves a mixed integer program (MIP) to maximize the Gini reduction (opt.model = 'gini') or minimize the number of misclassified cases (opt.model = 'error').

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 'enum_c', 'enum' indicating the algorithm to be used.

Value

a list containing the splitting solution.

Examples

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"))

[Package bsnsing version 1.0.1 Index]