predict.tda {transDA}R Documentation

Classification of new observations based on the model obtained by function 'tda'

Description

Predicts class memberships for new observations based on the model returned by function 'tda'.

Usage

## S3 method for class 'tda'
predict(object, newdata, ...)

Arguments

object

An object of class 'tda' produced by function tda

newdata

A data frame or matrix with data to be classified

...

Additional arguments that are passed to or from other methods

Value

classification

A factor containing predicted class labels for newdata

Z

A matrix of posterior probabilities for observations from newdata

See Also

tda

Examples

     set.seed(123)
     split_indices <- sample(nrow(iris), size = round(0.8 * nrow(iris)), replace = FALSE)
     split_indices <- sort(split_indices)
     traindata <- iris[split_indices,]
     testdata <- iris[-split_indices,]
     MDA <- tda(x = traindata[,1:4], max_k = 2, ID = traindata$Species, trans = FALSE)
     pred <- predict(MDA, testdata[,-5]); pred

[Package transDA version 1.0.1 Index]