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.
cfPredict(ensObj, newInputData)
cfBuild
inputData
, passed as an argument in cfBuild
.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:
cfBuild
. The application of a majority vote on these prediction scores generates the totalPred
matrix.cfBuild
## 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)
Run the code above in your browser using DataLab