HPLBmatrix {HPLB} | R Documentation |
Pairwise Total Variation Distance Lower Bound Matrix for the Multi-Class Setting
Description
Pairwise Total Variation Distance Lower Bound Matrix for the Multi-Class Setting
Usage
HPLBmatrix(
labels,
ordering.array,
alpha = 0.05,
computation.type = "non-optimized",
seed = 0,
...
)
Arguments
labels |
a numeric vector value. The labels of the classes, should be encoded in [0,nclass-1]. |
ordering.array |
a numeric array of size (nclass, nclass, nobs) such that the value (i,j,k) represents a propensity of being of class j instead of i for observation k. |
alpha |
a numeric value. The type-I error level. |
computation.type |
a character value. For the moment only "non-optimized" (default) available. |
seed |
an integer value. The seed for reproducility. |
... |
additional parameters to be passed to the HPLB function. |
Value
a numeric matrix of size (nclass, nclass) giving the matrix of pairwise total variation lower bounds.
Author(s)
Loris Michel, Jeffrey Naef
References
L. Michel, J. Naef and N. Meinshausen (2020). High-Probability Lower Bounds for the Total Variation Distance
Examples
# iris example
require(HPLB)
require(ranger)
# training a multi-class classifier on iris and getting tv lower bounds between classes
data("iris")
ind.train <- sample(1:nrow(iris), size = nrow(iris)/2, replace = FALSE)
rf <- ranger(Species~., data = iris[ind.train, ], probability = TRUE)
preds <- predict(rf, iris[-ind.train,])$predictions
# creating the ordering array based on prediction differences
ar <- array(dim = c(3, 3, nrow(preds)))
for (i in 1:3) {
for (j in 1:3) {
ar[i,j,] <- preds[,j] - preds[,i]
}
}
# encoding the class response
y <- factor(iris$Species)
levels(y) <- c(0,1,2)
y <- as.numeric(y)-1
# getting the lower bound matrix
tvhat.iris <- HPLBmatrix(labels = y[-ind.train], ordering.array = ar)
tvhat.iris