predict.dbcsp: Predict function implemented by dbcsp class

predict.dbcspR Documentation

Predict function implemented by dbcsp class

Description

This function returns the labels predicted for the input instances. If true_targets are passed as parameter, the accuracy obtained is printed too.

Usage

## S3 method for class 'dbcsp'
predict(object, X_test, true_targets=NULL, ...)

Arguments

object

object of class dbcsp.

X_test

list of matrices for test data.

true_targets

vector of true labels of the instances. Note that they must match the names of the labels used when training the model.

...

not currently used.

Details

It gives the predictions for the test data using the model saved in the object, which has been previously trained with the train.dbcsp function. If the true_targets are indicated, the confusion matrix and obtained accuracy value are returned too.

Value

The values returned by the LDA predict function, a list with these components:

  • class The MAP classification (a factor)

  • posterior Posterior probabilities for the classes

  • x The scores of test cases on up to dimen discriminant variables

If the true_targets are indicated, two more items are added to the output list:

  • confusion_matrix The confusion matrix obtained with predicted labels and true labels.

  • acc The accuracy value obtained for the test instances.

See Also

dbcsp, print, summary, train, selectQ, plot, boxplot

Examples

# Read data from 2 classes
x <- AR.data$come[1:20]
y <- AR.data$five[1:20]
mydbcsp <- new("dbcsp", X1 = x, X2 = y)
mydbcsp <- train(mydbcsp,fold=3)
test_data <- c(AR.data$come[20:24], AR.data$five[20:24])
test_labels <- c(rep('x',5),rep('y',5))
predictions <- predict(mydbcsp,test_data,test_labels)
# Predicted classes
print(predictions$class)
# Confusion matrix
print(predictions$confusion_matrix)
# Accuracy
print(predictions$acc)

dbcsp documentation built on June 30, 2022, 5:05 p.m.