compute_multilabel_predictions: Compute the multi-label ensemble predictions based on some...

Description Usage Arguments Value Note Examples

View source: R/ensemble.R

Description

Compute the multi-label ensemble predictions based on some vote schema

Usage

1
2
3
4
5
compute_multilabel_predictions(
  predictions,
  vote.schema = "maj",
  probability = getOption("utiml.use.probs", TRUE)
)

Arguments

predictions

A list of multi-label predictions (mlresult).

vote.schema

Define the way that ensemble must compute the predictions. The default valid options are:

'avg'

Compute the mean of probabilities and the bipartitions

'maj'

Compute the majority of votes

'max'

Compute the higher probability for each instance/label

'min'

Compute the lower probability for each instance/label

. (Default: 'maj')

probability

A logical value. If TRUE the predicted values are the score between 0 and 1, otherwise the values are bipartition 0 or 1.

Value

A mlresult with computed predictions.

Note

You can create your own vote schema, just create a method that receive two matrix (bipartitions and probabilities) and return a list with the final bipartitions and probabilities.

Remember that this method will compute the ensemble votes for each label. Thus the bipartition and probability matrix passed as argument for this method is related with the bipartitions and probabilities for a single label.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
model <- br(toyml, "KNN")
predictions <- list(
 predict(model, toyml[1:10], k=1),
 predict(model, toyml[1:10], k=3),
 predict(model, toyml[1:10], k=5)
)

result <- compute_multilabel_predictions(predictions, "maj")

## Random choice
random_choice <- function (bipartition, probability) {
 cols <- sample(seq(ncol(bipartition)), nrow(bipartition), replace = TRUE)
 list(
   bipartition = bipartition[cbind(seq(nrow(bipartition)), cols)],
   probability = probability[cbind(seq(nrow(probability)), cols)]
 )
}
result <- compute_multilabel_predictions(predictions, "random_choice")

utiml documentation built on May 31, 2021, 9:09 a.m.