Learn R Programming

tabularMLC (version 0.0.4)

predict.MLC.model: Predict function for MLC.model-class

Description

predict is inherited from the generic function for predictions from the results.

Usage

# S3 method for MLC.model
predict(object, x = NULL, likelihood = FALSE, ...)

Value

a factor vector with the predicted value. If likelihood is TRUE, then it will also return the calculated likelihoods.

Arguments

object

MLC.model-class model class to use for prediction

x

data.frame. The feature vector to predict

likelihood

logical. Whether to return or not the likelihood values, default FALSE.

...

inherited from generic function (not in use)

Examples

Run this code
data(iris)

n = length(iris$Species)

# Split training by sample
training = sample(1:n, size=n*0.7)
validation = (1:n)[-training]

# Train model with training dataset
mlcModel = MLC(Species ~ ., iris[training,])

# Predict using validation dataset
predict = predict(mlcModel, iris[validation,])

# Print confusion matrix
confusionMatrix = table(predicted=predict, observed=iris$Species[validation])
print(confusionMatrix)

Run the code above in your browser using DataLab