Learn R Programming

OmicsMarkeR (version 1.4.2)

predictNewClasses: Class Prediction

Description

This function evaluates a single fitted model and returns the predicted group memberships of new data.

Usage

predictNewClasses(modelFit, method, orig.data, newdata, param = NULL)

Arguments

modelFit
The fitted model being evaluated
method
String of the model to be evaluated
orig.data
The orginal data before subsetting training sets. Required to have the 'observed' group membership
newdata
The testing data to predict group membership
param
Optional alternate parameters being fit to the model

Value

Returns a list of predicted group membership

Examples

Run this code
dat.discr <- create.discr.matrix(
    create.corr.matrix(
        create.random.matrix(nvar = 50, 
                             nsamp = 100, 
                             st.dev = 1, 
                             perturb = 0.2)),
    D = 10
)

vars <- dat.discr$discr.mat
groups <- dat.discr$classes

fits <- fs.stability(vars, 
                     groups, 
                     method = c("plsda", "rf"), 
                     f = 10, 
                     k = 3, 
                     k.folds = 10, 
                     verbose = 'none')

newdata <- create.discr.matrix(
    create.corr.matrix(
        create.random.matrix(nvar = 50, 
                             nsamp = 100, 
                             st.dev = 1, 
                             perturb = 0.2)),
    D = 10
)$discr.mat

orig.df <- data.frame(vars, groups)

# see what the PLSDA predicts for the new data
# NOTE, newdata does not require a .classes column
predictNewClasses(fits, "plsda", orig.df, newdata)

Run the code above in your browser using DataLab