Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: svn+ssh://atolon.ugr.es/home/ts/code/trunk/Rpackages/RSNNS@464 4da2758a-f866-4958-9045-a385b76b148e
- Loading branch information
bergmeir
committed
Jan 9, 2012
1 parent
3f3fd65
commit ecf737f
Showing
11 changed files
with
116 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
library(RSNNS) | ||
|
||
basePath <- ("./") | ||
|
||
data(iris) | ||
|
||
seed <- 2 | ||
set.seed(seed) | ||
setSnnsRSeedValue(seed) | ||
|
||
#shuffle the vector | ||
#iris <- iris[sample(1:nrow(iris),length(1:nrow(iris))),1:ncol(iris)] | ||
|
||
#normalize data | ||
inputs <- normalizeData(iris[,1:4], "norm") | ||
|
||
#outputs <- decodeClassLabels(iris[,5]) | ||
outputs <- decodeClassLabels(iris[,5], valTrue=0.9, valFalse=0.1) | ||
|
||
numHiddenUnits <- 10 | ||
|
||
snnsObject <- SnnsRObjectFactory() | ||
|
||
snnsObject$setLearnFunc('Quickprop') | ||
snnsObject$setUpdateFunc('Topological_Order') | ||
snnsObject$setUnitDefaults(1,0,1,0,1,'Act_Logistic','Out_Identity') | ||
|
||
snnsObject$createNet(c(ncol(inputs),numHiddenUnits,ncol(outputs)), TRUE) | ||
|
||
patset <- snnsObject$createPatSet(inputs, outputs) | ||
snnsObject$setCurrPatSet(patset$set_no) | ||
|
||
snnsObject$shufflePatterns(TRUE) | ||
snnsObject$DefTrainSubPat() | ||
|
||
snnsObject$initializeNet(-1) | ||
|
||
snnsObject$saveNet(paste(basePath,"mlp_irisSnnsR_untrained.net",sep=""),"mlp_irisSnnsR_untrained.net") | ||
|
||
parameters <- c(0.2, 0, 0, 0, 0) | ||
maxit <- 100 | ||
|
||
error <- vector() | ||
for(i in 1:maxit) { | ||
res <- snnsObject$learnAllPatterns(parameters) | ||
error[i] <- res[[2]] | ||
} | ||
|
||
plot(error, type="l") | ||
|
||
predictions <- snnsObject$predictCurrPatSet("output", c(0)) | ||
|
||
confusionMatrix(outputs,predictions) | ||
|
||
snnsObject$saveNet(paste(basePath,"mlp_irisSnnsR.net",sep=""),"mlp_irisSnnsR") | ||
snnsObject$saveNewPatterns(paste(basePath,"mlp_irisSnnsR.pat",sep=""), patset$set_no) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
citHeader("To cite package 'RSNNS' in publications use:") | ||
|
||
citEntry(entry="Manual", | ||
title = "Neural Networks in R Using the Stuttgart Neural Network Simulator: RSNNS", | ||
author = "Christoph Bergmeir, Jos\\'e M. Ben\\'itez", | ||
year = 2010, | ||
note = "R package version 0.4-2", | ||
textVersion = "Christoph Bergmeir, Jose M. Benitez (2010). Neural Networks in R Using the Stuttgart Neural Network Simulator: RSNNS") | ||
citHeader("To cite RSNNS in publications use:") | ||
|
||
citEntry(entry = "Article", | ||
title = "Neural Networks in {R} Using the Stuttgart Neural Network Simulator: {RSNNS}", | ||
author = personList(as.person("Christoph Bergmeir"), | ||
as.person(" Jos\\'e M. Ben\\'itez")), | ||
journal = "Journal of Statistical Software", | ||
year = "2012", | ||
volume = "46", | ||
number = "7", | ||
pages = "1--26", | ||
url = "http://www.jstatsoft.org/v46/i07/", | ||
|
||
textVersion = | ||
paste("Christoph Bergmeir, Jose M. Benitez (2012).", | ||
"Neural Networks in R Using the Stuttgart Neural Network Simulator: RSNNS.", | ||
"Journal of Statistical Software, 46(7), 1-26.", | ||
"URL http://www.jstatsoft.org/v46/i07/.") | ||
) | ||
|