FFTrees (version 1.3.5)

comp.pred: Wrapper for classfication algorithms

Description

This function is a wrapper for many classification algorithms such as CART (rpart::rpart), logistic regression (glm), support vector machines (svm::svm) and random forests (randomForest::randomForest)

Usage

comp.pred(formula, data.train, data.test = NULL, algorithm = NULL,
  model = NULL, new.factors = "exclude")

Arguments

formula

a formula

data.train

dataframe. A training dataset

data.test

dataframe. A testing dataset

algorithm

string. An algorithm in the set "lr" -- logistic regression, cart" -- decision trees, "rlr" -- regularised logistic regression, "svm" -- support vector machines, "rf" -- random forests

model

model. An optional existing model applied to test data

new.factors

string. What should be done if new factor values are discovered in the test set? "exclude" = exclude (i.e.; remove these cases), "base" = predict the base rate of the criterion.

Examples

Run this code
# NOT RUN {
# Fit many alternative algorithms to the mushrooms dataset


mushrooms.cart.pred <- comp.pred(formula = poisonous ~.,
                               data.train = mushrooms[1:100,],
                               data.test = mushrooms[101:nrow(mushrooms),],
                               algorithm = "cart")

mushrooms.rf.pred <- comp.pred(formula = poisonous ~.,
                               data.train = mushrooms[1:100,],
                               data.test = mushrooms[101:nrow(mushrooms),],
                               algorithm = "rf")

mushrooms.svm.pred <- comp.pred(formula = poisonous ~.,
                               data.train = mushrooms[1:100,],
                               data.test = mushrooms[101:nrow(mushrooms),],
                               algorithm = "svm")



# }

Run the code above in your browser using DataLab