classify: Classification function

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Classify provided observations based on a given Discriminant object

Usage

1
classify(DA_object, newdata)

Arguments

DA_object

discriminant analysis object

newdata

vector or matrix or data frame with variables for which their classes will be calculated

Details

A DA_object is a discriminant analysis (DA) object obtained from a linear DA (class "linda") or a quadratic DA (class "quada").

Value

A list with the following elements

scores

discriminant scores for each observation

pred_class

predicted class

Author(s)

Gaston Sanchez

See Also

linDA, quaDA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  ## Not run: 
  # load iris dataset
  data(iris)

  # linear discriminant analysis
  my_lin1 = linDA(iris[,1:4], iris$Species)

  # select a sample of 15 observations
  set.seed(111)
  obs = sample(1:nrow(iris), 15)
  some_data = iris[obs, 1:4]
  
  # classify some_data
  get_classes = classify(my_lin1, some_data)
  get_classes
  
  # compare the results against original class
  table(iris$Species[obs], get_classes$pred_class)
  
## End(Not run)

nclSLR documentation built on May 2, 2019, 5:17 p.m.

Related to classify in nclSLR...