Description Usage Arguments Value Examples
View source: R/puSummaryThLoop.R
An example for a PU summary function which derives the maximum performance metric over a set of thresholds. Here 50 thresholds between the medians of the positive and unlabeled hold out predictions.
1 2 |
data |
a data frame or matrix with columns |
lev |
a character vector of factors levels for the response (default is |
model |
a character string for the model name (as taken form the method argument of train) (default is |
thresholds |
thresholds for which to calcualte the performance metrics |
maximize |
Charater (vector). The metrics to be maximized.
Must correspond to a name of the vector returned by |
returnAll |
return metrics for all thresholds. |
values of performance metrics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Not run:
data(bananas)
tuneGrid <- expand.grid(sigma=c(1:10)*rep(c(.1, 1), each=10),
nu=c(0.01, 0.05, 0.10, 0.15, 0.20, 0.25))
model <- trainOcc(x=bananas$tr[, -1], y=bananas$tr[, 1],
method="ocsvm", tuneGrid=tuneGrid)
model <- update(model, aggregatePredictions=TRUE,
metric="puFAP")
model <- update(model, aggregatePredictions=TRUE,
puSummaryFunction = puSummaryThLoop,
metric="thPuFAP")
pairs(model$results[, c("puF", "puFAP", "thPuFAP")])
mp.puF <- modelPosition(model, modRank=1, by="puF")
mp.puFAP <- modelPosition(model, modRank=1, by="puFAP")
mp.thPuFAP <- modelPosition(model, modRank=1, by="thPuFAP")
featurespace(update(model, modRow=mp.puF$row))
featurespace(update(model, modRow=mp.puFAP$row))
featurespace(update(model, modRow=mp.thPuFAP$row))
pred.puF <- predict(update(model, modRow=mp.puF$row),
bananas$x, returnRaster=FALSE)
pred.puFAP <- predict(update(model, modRow=mp.puFAP$row),
bananas$x, returnRaster=FALSE)
pred.thPuFAP <- predict(update(model, modRow=mp.thPuFAP$row),
bananas$x, returnRaster=FALSE)
hist(update(model, modRow=mp.puF$row), pred.puF)
hist(update(model, modRow=mp.puFAP$row), pred.puFAP)
hist(update(model, modRow=mp.thPuFAP$row), pred.thPuFAP)
abline(v=c(0, model$results[mp.thPuFAP$row, "thAP"] ))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.