predict.costprop: Predict method for Cost-Proportionate Classifier

Description Usage Arguments Examples

View source: R/costprop.R

Description

Predicts either the class or score according to predictions from classifiers fit to different resamples each. Be aware that the base classifier with which it was built must provide appropriate outputs that match with the arguments passed here ('type' and 'criterion'). This is usually managed through argument 'type' that goes to its 'predict' method.

Usage

1
2
3
## S3 method for class 'costprop'
predict(object, newdata, aggregation = "raw",
  output_type = "score", ...)

Arguments

object

An object of class 'costprop' as output by function 'cost.proportionate.classifier'.

newdata

New data on which to make predictions.

aggregation

One of "raw" (will take the class according to votes from each classifier. The predictions from classifiers must in turn be 1-dimensional vectors with the predicted class, not probabilities, scores, or two-dimensional arrays - in package 'caret' for example, this corresponds to 'type = "raw"'), or "weighted" (will take a weighted vote according to the probabilities or scores predicted by each classifier. The predictions from classifiers must in turn be either 1-dimensional vectors with the predicted probability/score, or two-dimensional matrices with the second column having the probability/score for the positive class = in package 'caret' for example, this corresponds to 'type = "prob').

output_type

One of "class" (will output the predicted class) or "score" (will output the predicted score).

...

Additional arguments to pass to the predict method of the base classifier.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
### example here requires 'caret' package
library(costsensitive)
data(iris)
set.seed(1)
X <- 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)

costsensitive documentation built on July 28, 2019, 5:02 p.m.