cfPredict: Predict the class of new data using an existing ensemble

Description Usage Arguments Value See Also Examples

View source: R/cfPredict.R

Description

The cfPredict function uses a classification ensemble object created by cfBuild to predict the class(es) of one or more samples described by a given data matrix. The function returns the predicted classes for each sample, together with a confidence score (between 0 and 100) which equates to the percentage of SVMs within the classifier that voted for the reported class.

Usage

1
cfPredict(ensObj, newInputData)

Arguments

ensObj

The classification ensemble (in the form of an R list) as generated by cfBuild

newInputData

A new independent dataset with unknown classes. The new dataset must have exactly the same number of columns as the inputData, passed as an argument in cfBuild.

Value

The cfPredict function returns an object in the form of an R list. The attributes of the list can be accessed by executing the attributes command. More specifically, the list of attributes includes:

totalPred

A matrix of the predicted classes as generated by a majority vote between the classifiers in the ensemble along with their confidence scores (the % percentage of the predicted class in the majority vote) for each sample.

indivPred

A matrix of the individual classes as predicted by each classifier in the ensemble. Each row represents a sample to be predicted, and each column an independent classification model in the ensemble as generated by cfBuild. The application of a majority vote on these prediction scores generates the totalPred matrix.

See Also

cfBuild

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Not run: 
data(iris)

irisClass <- iris[,5]
irisData  <- iris[,-5]

# Construct a classification ensemble with 100 classifiers and 100 bootstrap 
# iterations during optimisation

ens <- cfBuild(irisData, irisClass, bootNum = 100, ensNum = 100, parallel = TRUE, 
               cpus = 4, type = "SOCK")

# Randomly generate test data to find out their classes using the generated ensemble
# 400 points are selected at random, which results in 100 samples (rows).
# Predict the classes of the data using the classifiers in the constructed ensemble

testMatr <- matrix(runif(400)*100, ncol=4)           
predRes  <- cfPredict(ens, testMatr)

# Get the attributes of the object predRes 
attributes(predRes)$names

# Get the predicted classes as generated by a majority vote between the classifiers
predRes$totalPred

# Get the individual classes as predicted by each classifier in the ensemble
predRes$indivPred


## End(Not run)

classyfire documentation built on May 29, 2017, 11:05 p.m.