classify_bags: Classify y from bags

View source: R/utils.R

classify_bagsR Documentation

Classify y from bags

Description

Formally, this function applies max() on y for each level of bags.

Usage

classify_bags(y, bags, condense = TRUE)

Arguments

y

A numeric, character, or factor vector of bag labels for each instance. Must satisfy length(y) == nrow(x). Suggest that one of the levels is 1, '1', or TRUE, which becomes the positive class; otherwise, a positive class is chosen and a message will be supplied.

bags

A vector specifying which instance belongs to each bag. Can be a string, numeric, of factor.

condense

A logical (default TRUE) for whether to return classification at the level of unique bags or not.

Value

a named vector of length length(unique(b)) which gives the classification for each bag. Names come from bags.

Author(s)

Sean Kent

Examples

y <- c(1, 0, 0, 1, 1, 1, 0, 0, 0)
bags <- rep(1:3, each = 3)

classify_bags(y, bags)
classify_bags(y, bags, condense = FALSE)

# works with regular vector too
scores <- 1:9
classify_bags(scores, bags)


mildsvm documentation built on July 14, 2022, 9:08 a.m.