mixmodPredict: Create an instance of the ['MixmodPredict'] class

Description Usage Arguments Value Author(s) Examples

View source: R/MixmodPredict.R

Description

This function computes the second step of a discriminant analysis. The aim of this step is to assign remaining observations to one of the groups.

Usage

1
  mixmodPredict(data, classificationRule, ...)

Arguments

data

matrix or data frame containing quantitative,qualitative or composite data. Rows correspond to observations and columns correspond to variables.

classificationRule

a [MixmodResults] object which contains the classification rule computed in the mixmodLearn() or mixmodCluster() step.

...

internal

Value

Returns an instance of the [MixmodPredict] class which contains predicted partition and probabilities.

Author(s)

Florent Langrognet and Remi Lebret and Christian Poli and Serge Iovleff, with contributions from C. Biernacki and G. Celeux and G. Govaert [email protected]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# start by extract 10 observations from iris data set
  remaining.obs<-sample(1:nrow(iris),10)
  # then run a mixmodLearn() analysis without those 10 observations
  learn<-mixmodLearn(iris[-remaining.obs,1:4], iris$Species[-remaining.obs])
  # create a MixmodPredict to predict those 10 observations
  prediction <- mixmodPredict(data=iris[remaining.obs,1:4], classificationRule=learn["bestResult"])
  # show results
  prediction
  # compare prediction with real results
  paste("accuracy= ",mean(as.integer(iris$Species[remaining.obs]) == prediction["partition"])*100
        ,"%",sep="")

  ## A composite example with a heterogeneous data set
  data(heterodatatrain)
  ## Learning with training data
  learn <- mixmodLearn(heterodatatrain[-1],knownLabels=heterodatatrain$V1)
  ## Prediction on the testing data
  data(heterodatatest)
  prediction <- mixmodPredict(heterodatatest[-1],learn["bestResult"])
  # compare prediction with real results
  paste("accuracy= ",mean(heterodatatest$V1 == prediction["partition"])*100,"%",sep="")

Rmixmod documentation built on May 30, 2017, 3:31 a.m.