MLInterfaces (version 1.48.0)

predict.classifierOutput: Predict method for classifierOutput objects

Description

This function predicts values based on models trained with MLInterfaces' MLearn interface to many machine learning algorithms.

Usage

"predict"(object, newdata, ...)

Arguments

object
An instance of class classifierOutput.
newdata
An object containing the new input data: either a matrix, a data.frame or an ExpressionSet.
...
Other arguments to be passed to the algorithm-specific predict methods.

Value

Currently, a list with
testPredictions
A factor with class predictions.
testScores
A numeric or matrix with class probabilities.

Details

This S3 method will extract the ML model from the classifierOutput instance and call either a generic predict method or, if available, a specficly written wrapper to do classes prediction and class probabilities.

See Also

MLearn and classifierOutput.

Examples

Run this code
set.seed(1234)
data(sample.ExpressionSet)
trainInd <- 1:16

clout.svm <- MLearn(type~., sample.ExpressionSet[100:250,], svmI, trainInd)
predict(clout.svm, sample.ExpressionSet[100:250,-trainInd])

clout.ksvm <- MLearn(type~., sample.ExpressionSet[100:250,], ksvmI, trainInd)
predict(clout.ksvm, sample.ExpressionSet[100:250,-trainInd])

clout.nnet <- MLearn(type~., sample.ExpressionSet[100:250,], nnetI, trainInd, size=3, decay=.01 )
predict(clout.nnet, sample.ExpressionSet[100:250,-trainInd])

clout.knn <- MLearn(type~., sample.ExpressionSet[100:250,], knnI(k=3), trainInd)
predict(clout.knn, sample.ExpressionSet[100:250,-trainInd],k=1)
predict(clout.knn, sample.ExpressionSet[100:250,-trainInd],k=3)

clout.plsda <- MLearn(type~., sample.ExpressionSet[100:250,], plsdaI, trainInd)
predict(clout.plsda, sample.ExpressionSet[100:250,-trainInd])

clout.nb <- MLearn(type~., sample.ExpressionSet[100:250,], naiveBayesI, trainInd)
predict(clout.nb, sample.ExpressionSet[100:250,-trainInd])

# this can fail if training set does not yield sufficient diversity in response vector;
# setting seed seems to help with this example, but other applications may have problems
#
clout.rf <- MLearn(type~., sample.ExpressionSet[100:250,], randomForestI, trainInd)
predict(clout.rf, sample.ExpressionSet[100:250,-trainInd])

Run the code above in your browser using DataCamp Workspace