predict.treeda: Predict using new data

Description Usage Arguments Value Examples

View source: R/treeda-functions.R

Description

Given a fitted treeda model, get the predicted classes and projections onto the discriminating axes for new data.

Usage

1
2
## S3 method for class 'treeda'
predict(object, newdata, newresponse = NULL, check.consist = TRUE, ...)

Arguments

object

Output from treeda function.

newdata

New predictor matrix in the same format as the predictor argument to treeda. A matrix of predictor variables corresponding to the leaves of the tree and in the same order as the leaves of the tree.

newresponse

New response vector, not required.

check.consist

Check the consistency between the tree and predictor matrix?

...

Not used.

Value

A list containing the projections of the new data onto the discriminating axes (projections), the predicted classes (classes), and the rss (rss, only included if the ground truth for the responses is available).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(treeda_example)
out.treeda = treeda(response = treeda_example$response,
    predictors = treeda_example$predictors,
    tree = treeda_example$tree,
    p = 1)
## Here we are predicting on the training data, in general this
## would be done on a held out test set
preds = predict(out.treeda, newdata = treeda_example$predictors,
    newresponse = treeda_example$response)
## make a confusion matrix
table(preds$classes, treeda_example$response)

jfukuyama/treeDA documentation built on May 18, 2021, 8:52 a.m.