cost.proportionate.classifier {costsensitive}R Documentation

Cost-Proportionate Classifier

Description

Fits a classifier with sample weights by reducing the problem to classification without sample weights through rejection sampling.

Usage

cost.proportionate.classifier(X, y, weights, classifier, nsamples = 10,
  extra_rej_const = 0.1, nthreads = 1, seed = 1, ...)

Arguments

X

Features/Covariates for each observation.

y

Class for each observation.

weights

Weights for each observation.

classifier

Base classifier to use.

nsamples

Number of resamples to take.

extra_rej_const

Extra rejection constant - the higher, the smaller each sample ends up being, but the smallest the chance that the highest-weighted observations would end up in each sample.

nthreads

Number of parallel threads to use (not available on Windows systems). Note that, unlike the Python version, this is not a shared memory model and each additional thread will require more memory from the system. Not recommended to use when the algorithm is itself parallelized.

seed

Random seed to use for the random number generation.

...

Additional arguments to pass to 'classifier'.

References

Beygelzimer, A., Langford, J., & Zadrozny, B. (2008). Machine learning techniques-reductions between prediction quality metrics.

Examples

## Not run: 
### example here requires 'caret' package
library(costsensitive)
data(iris)
set.seed(1)
X <- iris[, c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")]
y <- factor(iris$Species == "setosa", labels = c("class1", "class2"))
weights <- rgamma(100, 1)
classifier <- caret::train
model <- cost.proportionate.classifier(X, y, weights, classifier,
  method = "glm", family = "binomial",
  trControl=caret::trainControl(method="none"), tuneLength=1)
predict(model, X, aggregation = "raw", type = "raw")
predict(model, X, aggregation = "weighted", type = "prob")

## End(Not run)

[Package costsensitive version 0.1.2.10 Index]