hit.curve: Plot hit curve

Description Usage Arguments Details Value Examples

View source: R/hitcurve.R

Description

Plots the hit curve corresponding to phat and y.

Usage

1
hit.curve(y, phat, max.cutoff = min(100, length(y)), plot.hc = T, ...)

Arguments

y

True binary response vector where 1 denotes the relevant rare class.

phat

Vector of estimated probabilities of relevance.

max.cutoff

Maximum number of observations selected, equivalently the maximum shortlist cutoff; default is min(100, length(y)).

plot.hc

Whether to return a plot of the hit curve; default is TRUE.

...

Further arguments passed to or from other methods.

Details

Order the cases by decreasing phat (predicted probabilities of relevance) values, and plot the expected number and actual number of hits as cases are selected. Cases with tied phat values are grouped together. See plot.epx for plotting the hit curve for an "epx" object.

Value

Plot of the hit curve (if plot.hc = TRUE) and a list with the following vectors:

select

Number of observations in each tied phat group; select[1], select[2], ... are the numbers of observations with the largest predicted probability of relevance (max(phat)), the second largest value in phat, etc.

p

Unique phat values; p[1], p[2], ... are the largest value in phat, the second largest value in phat, etc.

nhits

Number of hits (truly relevant observations) in each tied phat group.

nhitlast

Number of hits after max.cutoff observations selected.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Example with data(harvest)

## Phalanx-formation using a base classifier with 50 trees (default = 500)

set.seed(761)
model <- epx(x = harvest[, -4], y = harvest[, 4],
             classifier.args = list(ntree = 50))

## Plot hit curve for cross-validated predicted probabilities of relevence
set.seed(761)
model.cv <- cv.epx(model)
preds.cv <- model.cv[-nrow(model.cv), ncol(model.cv)]
cv.hc <- hit.curve(phat = as.numeric(preds.cv), y = model$Y)

EPX documentation built on July 7, 2021, 1:06 a.m.