Learn R Programming

mildsvm (version 0.4.1)

classify_bags: Classify y from bags

Description

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

Usage

classify_bags(y, bags, condense = TRUE)

Value

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

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.

Author

Sean Kent

Examples

Run this code
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)

Run the code above in your browser using DataLab