predictNewClasses: Class Prediction

Description Usage Arguments Value Examples

View source: R/predictNewClasses.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)

OmicsMarkeR documentation built on April 28, 2020, 6:54 p.m.