fixed_threshold: Apply a fixed threshold in the results

Description Usage Arguments Value Methods (by class) References See Also Examples

Description

Transform a prediction matrix with scores/probabilities in a mlresult applying a fixed threshold. A global fixed threshold can be used of all labels or different fixed thresholds, one for each label.

Usage

1
2
3
4
5
6
7
fixed_threshold(prediction, threshold = 0.5, probability = FALSE)

## Default S3 method:
fixed_threshold(prediction, threshold = 0.5, probability = FALSE)

## S3 method for class 'mlresult'
fixed_threshold(prediction, threshold = 0.5, probability = FALSE)

Arguments

prediction

A matrix with scores/probabilities where the columns are the labels and the rows are the instances.

threshold

A single value between 0 and 1 or a list with threshold values contained one value per label.

probability

A logical value. If TRUE the predicted values are the score between 0 and 1, otherwise the values are bipartition 0 or 1. (Default: FALSE)

Value

A mlresult object.

Methods (by class)

References

Al-Otaibi, R., Flach, P., & Kull, M. (2014). Multi-label Classification: A Comparative Study on Threshold Selection Methods. In First International Workshop on Learning over Multiple Contexts (LMCE) at ECML-PKDD 2014.

See Also

Other threshold: lcard_threshold(), mcut_threshold(), pcut_threshold(), rcut_threshold(), scut_threshold(), subset_correction()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Create a prediction matrix with scores
result <- matrix(
 data = rnorm(9, 0.5, 0.2),
 ncol = 3,
 dimnames = list(NULL, c('lbl1',  'lb2', 'lb3'))
)

# Use 0.5 as threshold
fixed_threshold(result)

# Use an threshold for each label
fixed_threshold(result, c(0.4, 0.6, 0.7))

Example output

Loading required package: mldr
     lbl1 lb2 lb3
[1,]    0   0   1
[2,]    0   1   1
[3,]    0   1   1
     lbl1 lb2 lb3
[1,]    0   0   1
[2,]    1   1   0
[3,]    0   1   0

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