undersampling: Undersampling

Description Usage Arguments Value Examples

Description

Undersampling the majority class with rate = beta, where beta is the probability of selecting a negative instance during undersampling. The probability estimate is calibrated to adjust it for class prior change

Usage

1
2
undersampling(task, lrn, beta, metrics, rdesc = NULL, positive, negative,
  verbose = TRUE, dirPlot = NA, ncore = 1, type = "within", B = 1)

Arguments

task

classification task to perform (see mlr package)

lrn

learner to use with the task (see mlr package)

beta

probability of selecting a negative instance during undersampling

metrics

metrics to asess classification performances

rdesc

resampling methods to use (see mlr package)

positive

value of the positive (minority) class

negative

value of the negative (majority) class

verbose

print extra information (logical variable)

dirPlot

directory where to save plots (set dirPlot=NA to avoid plots)

ncore

number of cores to use in multicore computation

type

way to apply undersampling: within or before the CV

B

number of models to create for each fold of the CV

Value

The function returns a list:

under

results with undersampling

cal

results after calibration

pred.under

predictions with undersampling

pred.cal

predictions after calibration

prob

posterior probability of the classifier for the positive class

Examples

1
2
3
4
5
6
7
8
9
library(mlbench)
data(Ionosphere)
library(mlr)
task <- makeClassifTask(data=Ionosphere, target="Class", positive="bad")
library(randomForest)
rf <- makeLearner("classif.randomForest", predict.type = "prob")
metrics <- list(f1, auc)
library(warping)
res <- undersampling(task, rf, beta=0.6, metrics, positive="bad", negative="good")

dalpozz/warping documentation built on May 14, 2019, 3:32 p.m.