Learn R Programming

FFTrees (version 1.6.6)

predict.FFTrees: Predict classifications from newdata using an FFTrees object

Description

Predict classifications from newdata using an FFTrees object

Usage

# S3 method for FFTrees
predict(
  object = NULL,
  newdata = NULL,
  tree = 1,
  type = "class",
  sens.w = NULL,
  method = "laplace",
  data = NULL,
  ...
)

Value

Either a logical vector of predictions, or a matrix of class probabilities.

Arguments

object

An FFTrees object created from the FFTrees() function.

newdata

dataframe. A dataframe of test data

tree

integer. Which tree in the object should be used? By default, tree = 1 is used

type

string. What should be predicted? Can be "class", which returns a vector of class predictions, "prob" which returns a matrix of class probabilities, or "both" which returns a matrix with both class and probability predictions.

sens.w, data

deprecated

method

string. Method of calculating class probabilities. Either 'laplace', which applies the Laplace correction, or 'raw' which applies no correction.

...

Additional arguments passed on to predict()

Examples

Run this code


# Create training and test data

set.seed(100)
breastcancer <- breastcancer[sample(nrow(breastcancer)), ]
breast.train <- breastcancer[1:150, ]
breast.test <- breastcancer[151:303, ]

# Create an FFTrees x from the training data

breast.fft <- FFTrees(
  formula = diagnosis ~ .,
  data = breast.train
)

# Predict classes of test data
breast.fft.pred <- predict(breast.fft,
  newdata = breast.test
)

# Predict class probabilities
breast.fft.pred <- predict(breast.fft,
  newdata = breast.test,
  type = "prob"
)

Run the code above in your browser using DataLab