Last data update: 2014.03.03

R: Predicts from a fitted GAMens object (i.e., GAMbag, GAMrsm or...
predict.GAMensR Documentation

Predicts from a fitted GAMens object (i.e., GAMbag, GAMrsm or GAMens classifier).

Description

Generates predictions (classes and class membership probabilities) for observations in a dataframe using a GAMens object (i.e., GAMens, GAMrsm or GAMbag classifier).

Usage

## S3 method for class 'GAMens'
predict(object, data,...)

Arguments

object

fitted model object of GAMens class.

data

data frame with observations to genenerate predictions for.

...

further arguments passed to or from other methods.

Value

An object of class predict.GAMens, which is a list with the following components:

pred

the class membership probabilities generated by the ensemble classifier.

class

the classes predicted by the ensemble classifier.

conf

the confusion matrix which compares the real versus predicted class memberships, based on the class object. Obtains value NULL if the testdata is unlabeled.

Author(s)

Koen W. De Bock K.DeBock@ieseg.fr, Kristof Coussement K.Coussement@ieseg.fr and Dirk Van den Poel Dirk.VandenPoel@ugent.be

References

De Bock, K. W. and Van den Poel, D. (2012): "Reconciling Performance and Interpretability in Customer Churn Prediction Modeling Using Ensemble Learning Based on Generalized Additive Models". Expert Systems With Applications, Vol 39, 8, pp. 6816–6826.

De Bock, K. W., Coussement, K. and Van den Poel, D. (2010): "Ensemble Classification based on generalized additive models". Computational Statistics & Data Analysis, Vol 54, 6, pp. 1535–1546.

Breiman, L. (1996): "Bagging predictors". Machine Learning, Vol 24, 2, pp. 123–140.

Hastie, T. and Tibshirani, R. (1990): "Generalized Additive Models", Chapman and Hall, London.

Ho, T. K. (1998): "The random subspace method for constructing decision forests". IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol 20, 8, pp. 832–844.

See Also

GAMens, GAMens.cv

Examples

## Load data, mlbench library should be loaded!)
library(mlbench)
data(Sonar)

## Select indexes for training set observations
idx <- c(sample(1:97,60),sample(98:208,70))

## Train GAMrsm using all variables in Sonar dataset. Generate predictions
## for test set observations.
Sonar.GAMrsm <- GAMens(Class~.,Sonar[idx,], autoform=TRUE, iter=10,
bagging=FALSE, rsm=TRUE)
Sonar.GAMrsm.predict <- predict.GAMens(Sonar.GAMrsm,Sonar[-idx,])


## Load data mlbench library should be loaded!)
library(mlbench)
data(Ionosphere)
Ionosphere_s <- Ionosphere[order(Ionosphere[,35]),]

## Select indexes for training set observations
idx <- c(sample(1:97,60),sample(98:208,70))

## Train a GAMrsm ensemble classifier
## using using 4 nonparametric terms and 2 linear terms in the
## Ionosphere dataset

Ionosphere.GAMrsm <- GAMens(Class~s(V3,4)+s(V4,4)+s(V5,3)+s(V6,5)+V7+V8,
Ionosphere[idx,], autoform=FALSE, iter=10, bagging=FALSE, rsm=TRUE)

Ionosphere.GAMrsm.predict <- predict.GAMens(Ionosphere.GAMrsm,
Ionosphere[-idx,])

## Calculate AUC (for function colAUC, load caTools library) for the GAMrsm model
library(caTools)

GAMrsm.auc <- colAUC(Ionosphere.GAMrsm.predict[[1]],
Ionosphere[-idx,"Class"]=="good", plotROC=FALSE)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(GAMens)
Loading required package: splines
Loading required package: gam
Loading required package: foreach
Loaded gam 1.12

Loading required package: mlbench
Loading required package: caTools
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GAMens/predict.GAMens.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predict.GAMens
> ### Title: Predicts from a fitted GAMens object (i.e., GAMbag, GAMrsm or
> ###   GAMens classifier).
> ### Aliases: predict.GAMens
> ### Keywords: models classif
> 
> ### ** Examples
> 
> ## Load data, mlbench library should be loaded!)
> library(mlbench)
> data(Sonar)
> 
> ## Select indexes for training set observations
> idx <- c(sample(1:97,60),sample(98:208,70))
> 
> ## Train GAMrsm using all variables in Sonar dataset. Generate predictions
> ## for test set observations.
> Sonar.GAMrsm <- GAMens(Class~.,Sonar[idx,], autoform=TRUE, iter=10,
+ bagging=FALSE, rsm=TRUE)
> Sonar.GAMrsm.predict <- predict.GAMens(Sonar.GAMrsm,Sonar[-idx,])
> 
> 
> ## Load data mlbench library should be loaded!)
> library(mlbench)
> data(Ionosphere)
> Ionosphere_s <- Ionosphere[order(Ionosphere[,35]),]
> 
> ## Select indexes for training set observations
> idx <- c(sample(1:97,60),sample(98:208,70))
> 
> ## Train a GAMrsm ensemble classifier
> ## using using 4 nonparametric terms and 2 linear terms in the
> ## Ionosphere dataset
> 
> Ionosphere.GAMrsm <- GAMens(Class~s(V3,4)+s(V4,4)+s(V5,3)+s(V6,5)+V7+V8,
+ Ionosphere[idx,], autoform=FALSE, iter=10, bagging=FALSE, rsm=TRUE)
> 
> Ionosphere.GAMrsm.predict <- predict.GAMens(Ionosphere.GAMrsm,
+ Ionosphere[-idx,])
> 
> ## Calculate AUC (for function colAUC, load caTools library) for the GAMrsm model
> library(caTools)
> 
> GAMrsm.auc <- colAUC(Ionosphere.GAMrsm.predict[[1]],
+ Ionosphere[-idx,"Class"]=="good", plotROC=FALSE)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>