cspnn.predict: cspnn.predict

Description Usage Arguments Details Value See Also Examples

View source: R/cspnn.predict.R

Description

Estimates the category probabilities of new observations using a fitted CSPNN.

Usage

1
cspnn.predict(nn, newData)

Arguments

nn

A trained Condensed Scaled Invariant Probabilistic Neural Network.

newData

A matrix of new observations where each row represents a single observation vector.

Details

Given a trained Condensed Scale Invariant Probabilistic Neural Network and new data, the function cspnn.predict returns the category with the highest probability and the probability estimates for each category.

Value

A list of the guessed categories and the probability estimates of each category.

See Also

spnn-package, cspnn.learn, iris

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
library(spnn)
library(datasets)

data(iris)

# shuffle the iris data set
indexRandom <- sample(1:nrow(iris), size = nrow(iris), replace = FALSE)

# use 100 observations for training set
trainData <- iris[indexRandom[1:100],]

# use remaining observations for testing
testData <- iris[indexRandom[101:length(indexRandom)],]

# reference matrix must be supplied
xr <- matrix(c(c(5.00, 3.41, 1.44, 0.24),
               c(5.88, 2.75, 4.23, 1.30),
               c(6.61, 2.97, 5.59, 2.01)),
             nrow = length(unique(trainData$Species)),
             ncol = ncol(trainData) - 1,
             byrow = TRUE) # this is not the optimal reference matrix

# fit cspnn
cspnn <- cspnn.learn(set = trainData, xr = xr, category.column = 5)

# estimate probabilities
predictions <- cspnn.predict(nn = cspnn, newData = testData[,1:4])

spnn documentation built on Sept. 12, 2019, 5:04 p.m.