klaR (version 0.6-1)

predict.locpvs: predict method for locpvs objects

Description

Prediction of class membership and posterior probabilities in local models using pairwise variable selection.

Usage

## S3 method for class 'locpvs':
predict(object,newdata, quick = FALSE, return.subclass.prediction = TRUE, ...)

Arguments

object
an object of class locpvs, as that created by the function locpvs
newdata
a data frame or matrix containing new data. If not given the same datas as used for training the pvs-model are used.
quick
indicator (logical), whether a quick, but less accurate computation of posterior probabalities should be used or not.
return.subclass.prediction
indicator (logical), whether the returned object includes posterior probabilities for each date in each subclass
...
Further arguments are passed to underlying predict calls.

Value

  • a list with components:
  • classthe predicted (upper) classes
  • posteriorposterior probabilities for the (upper) classes
  • subclass.posteriors(only if return.subclass.prediction=TRUE. A matrix containing posterior probabalities for the subclasses.

concept

Pairwise variable selection for classification

Details

Posterior probabilities are predicted as if object is a standard pvs-model with the subclasses as classes. Then the posterior probabalities are summed over all subclasses for each class. The class with the highest value becomes the prediction. If quick=FALSE the posterior probabilites for each case are computed using the pairwise coupling algorithm presented by Hastie, Tibshirani (1998). If quick=FALSE a much quicker solution is used, which leads to less accurate posterior probabalities. In almost all cases it doesn't has a negative effect on the classification result.

References

Szepannek, G. and Weihs, C. (2006) Local Modelling in Classification on Different Feature Subspaces. In Advances in Data Mining., ed Perner, P., LNAI 4065, pp. 226-234. Springer, Heidelberg.

See Also

locpvs for learning locpvs-models, pvs for pairwise variable selection without modeling subclasses, predict.pvs for predicting pvs-models

Examples

Run this code
## this example might be a bit artificial, but it sufficiently shows how locpvs has to be used

## learn a locpvs-model on the Vehicle dataset

library("mlbench")
data("Vehicle")

subclass <- Vehicle$Class # use four car-types in dataset as subclasses
## aggregate "bus" and "van" to upper-class "big" and "saab" and "opel" to upper-class "small":
subclass_class <- matrix(c("bus","van","saab","opel","big","big","small","small"), ncol=2) 

## learn now a locpvs-model for the subclasses:
model <- locpvs(Vehicle[,1:18], subclass, subclass_class)
model # short summary, showing the class-pairs of the submodels 
# together with the selected variables and the relation of sub- to upperclasses

## predict:
pred <- predict(model,Vehicle[,1:18])

## now you can look at the predicted classes:
pred$class
## or at the posterior probabilities:
pred$posterior
## or at the posterior probabilities for the subclasses:
pred$subclass.posteriors

Run the code above in your browser using DataCamp Workspace