nn.test: Test new samples by Trainded NN

Description Usage Arguments Value Author(s) Examples

Description

Test new samples by Trainded NN,return error rate for classification

Usage

1
nn.test(nn, x, y, t = 0.5)

Arguments

nn

nerual network trained by function nn.train

x

new samples to predict

y

new samples' label

t

threshold for classification. If nn.predict value >= t then label 1,else label 0

Value

error rate

Author(s)

Xiao Rong

Examples

1
2
3
4
5
6
7
8
9
Var1 <- c(rnorm(50,1,0.5),rnorm(50,-0.6,0.2))
Var2 <- c(rnorm(50,-0.8,0.2),rnorm(50,2,1))
x <- matrix(c(Var1,Var2),nrow=100,ncol=2)
y <- c(rep(1,50),rep(0,50))
nn <-nn.train(x,y,hidden=c(5))
test_Var1 <- c(rnorm(50,1,0.5),rnorm(50,-0.6,0.2))
test_Var2 <- c(rnorm(50,-0.8,0.2),rnorm(50,2,1))
test_x <- matrix(c(test_Var1,test_Var2),nrow=100,ncol=2)
err <- nn.test(nn,test_x,y)

DimitriF/DLC documentation built on Oct. 14, 2020, 4:33 p.m.