tally: 'tally' is used to fit a tallying model.

tallyR Documentation

tally is used to fit a tallying model.

Description

tally is used to fit a tallying model.

Usage

tally(
  data,
  formula = stats::as.formula(data.frame(data)),
  method = "basic",
  max_size = 6,
  split_function = "gini",
  weights = c(1, 1),
  cv = FALSE,
  cross_entropy_parameters = cross_entropy_control()
)

## S4 method for signature 'data.frame'
tally(
  data,
  formula = stats::as.formula(data.frame(data)),
  method = "basic",
  max_size = 6,
  split_function = "gini",
  weights = c(1, 1),
  cv = FALSE,
  cross_entropy_parameters = cross_entropy_control()
)

## S4 method for signature 'matrix'
tally(
  data,
  formula = stats::as.formula(data.frame(data)),
  method = "basic",
  max_size = 6,
  split_function = "gini",
  weights = c(1, 1),
  cv = FALSE,
  cross_entropy_parameters = cross_entropy_control()
)

Arguments

data

An object of class data.frame or matrix. The response variable can either be a factor with two levels or an integer vector with values 0,1.

formula

formula (optional). If formula is not provided, the first column of the data argument is used as the response variable and all other columns as predictors.

method

Type of induction method for the fast-and-frugal tree:

  • basic (default)

  • cross-entropy

max_size

Maximum number of features that contribute to the tallying model (default: 6)

split_function

Function should be used to determine the splitting values on numeric features. This only applies to tallying models trained with the 'basic' method. By default Gini entropy ('gini') is used. Other options are Shannono entropy ('entropy') and 'median'.

weights

A numeric vector of length 2 (default: c(1,1)) with weights assigned to instances in the two classes. The vector entries should be named by the class labels. If they are not, the first entry refers to the negative class, the second entry to the positive class. (see examples).

cv

If TRUE 10-fold cross validation is used to estimate the predictive performance of the model. By default, pruning is not used.

cross_entropy_parameters

Hyperparameters for the cross-entropy method. By default the output of the function cross_entropy_control is passed.

Value

A tallyModel object.

Examples

data(liver)
model <- tally(data = liver, formula = diagnosis~.)
model

# weight instances by the inverse of the prior
# in this way both classes contribute equally when training the model
prior <- mean(ifelse(liver$diagnosis == "Liver disease", 1, 0))
weights <- c("No liver disease" = prior, "Liver disease" = 1-prior)
mod <- tally(data = liver, formula = diagnosis~., weights = weights)


marcusbuckmann/ffcr documentation built on Jan. 4, 2024, 3:45 p.m.