Skip to content

Commit

Permalink
RSNNS 0.4-3: see ChangeLog
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 40 deletions.
10 changes: 9 additions & 1 deletion ChangeLog
@@ -1,3 +1,11 @@
version 0.4-3 (09-1-2012):

- included a citation to the JSS article about RSNNS in the documentation and the CITATION file
- recompressed example data to fix a warning in CRAN checks
- fixed the jordan and elman examples: "decay=0.1" was given as parameter, instead of the correct "learnFuncParams=c(0.1)"
- added an example for training an MLP for the iris data, using the low-level api (mlp_irisSnnsR.R)
- fixed the decodeClassLables() function, which didn't correctly translate factor level names to column names

version 0.4-2 (29-9-2011):

- removed original SNNS manual, to avoid license confusions, as it states an outdated license
Expand All @@ -13,7 +21,7 @@ version 0.4-0 (21-6-2011):
- The art2 demo was fixed
- changed package encoding to UTF-8
- wrapping of some of the missing functions was added
- artmap was added in the high-level interfact
- artmap was added in the high-level interface
- initialization to zero was added for all former static variables
(this was not always performed before, but it turned out that some
SNNS functions rely on this and crash otherwise, e.g. dlvq and artmap)
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Expand Up @@ -6,7 +6,7 @@ Title: Neural Networks in R using the Stuttgart Neural Network
LinkingTo: Rcpp
Type: Package
LazyLoad: yes
Author: Christoph Bergmeir <c.bergmeir@decsai.ugr.es>
Author: Christoph Bergmeir and José M. Benítez
Description: The Stuttgart Neural Network Simulator (SNNS) is a library
containing many standard implementations of neural networks. This
package wraps the SNNS functionality to make it available from
Expand All @@ -15,9 +15,9 @@ Description: The Stuttgart Neural Network Simulator (SNNS) is a library
Furthermore, the package contains a convenient high-level
interface, so that the most common neural network topologies and
learning algorithms integrate seamlessly into R.
Version: 0.4-2
Version: 0.4-3
URL: http://sci2s.ugr.es/dicits/software/RSNNS
Date: 2011-09-29
Date: 2012-01-09
Depends: R (>= 2.10.0), methods, Rcpp (>= 0.8.5)
Suggests: scatterplot3d
Encoding: UTF-8
Expand Down
9 changes: 8 additions & 1 deletion R/RSNNS-package.R
Expand Up @@ -40,6 +40,10 @@
#' If you have problems using RSNNS, find a bug, or have suggestions, please contact the package maintainer by email, instead of writing to the general R lists or contacting the
#' authors of the original SNNS software.
#'
#' If you use the package, please cite the following work in your publications:
#'
#' Bergmeir, C. and Benítez, J.M. (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/}
#'
#' The package has a hierarchical architecture with three levels:
#' \itemize{
#' \item RSNNS high-level api (rsnns)
Expand Down Expand Up @@ -96,14 +100,17 @@
# @encoding Latin-1
#' @author Christoph Bergmeir \email{c.bergmeir@@decsai.ugr.es}
#'
#' with José M. Benítez \email{j.m.benitez@@decsai.ugr.es}
#' and José M. Benítez \email{j.m.benitez@@decsai.ugr.es}
#'
#' DiCITS Lab, Sci2s group, DECSAI, University of Granada.
#'
#' \url{http://dicits.ugr.es}, \url{http://sci2s.ugr.es}
#'
#' @references
#'
#' Bergmeir, C. and Benítez, J.M. (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/}
#'
#' \emph{General neural network literature:}
#'
#' Bishop, C. M. (2003), Neural networks for pattern recognition, University Press, Oxford.
Expand Down
4 changes: 2 additions & 2 deletions R/elman.R
Expand Up @@ -88,9 +88,9 @@ elman <- function(x, ...) UseMethod("elman")
#'
#' par(mfrow=c(1,2))
#'
#' modelElman <- elman(inputs, outputs, size=8, decay=0.1, maxit=1000)
#' modelElman <- elman(inputs, outputs, size=8, learnFuncParams=c(0.1), maxit=1000)
#' modelElman
#' modelJordan <- jordan(inputs, outputs, size=8, decay=0.1, maxit=1000)
#' modelJordan <- jordan(inputs, outputs, size=8, learnFuncParams=c(0.1), maxit=1000)
#' modelJordan
#'
#' plotIterativeError(modelElman)
Expand Down
35 changes: 13 additions & 22 deletions R/reg_class.R
Expand Up @@ -183,41 +183,32 @@ plotIterativeError.rsnns <- function(object, ...)
#' 100 001 010 001
#'
#' @title Decode class labels to a binary matrix
#' @references
#' Venables, W. N. and Ripley, B. D. (2002), 'Modern Applied Statistics with S', Springer-Verlag.
#' @param x class label vector
#' @param valTrue see Details paragraph
#' @param valFalse see Details paragraph
#' @return a matrix containing the decoded class labels
#' @export
#' @author The implementation is a slightly modified version of the function \code{class.ind} from the \code{nnet} package of Brian Ripley.
#' @examples
#' decodeClassLabels(c(1,3,2,3))
#' decodeClassLabels(c("r","b","b","r", "g", "g"))
#'
#' data(iris)
#' decodeClassLabels(iris[,5])
decodeClassLabels <- function(x, valTrue=1, valFalse=0) {

#y <- gl(2, 4, 8)
#levels(y) <- c("low", "high")
#if(length(levels(y))!=0) {}

classes <- unique(x)
numClasses <- 1:length(classes)
names(numClasses) <- classes

targets <- matrix(nrow=length(x), ncol=length(classes))
for(i in 1:length(x))
for(j in numClasses) {
if(j == numClasses[x[i]]) {
targets[i,j] <- valTrue
}
else {
targets[i,j] <- valFalse
}
}
decodeClassLabels <- function(x, valTrue=1, valFalse=0)
{
n <- length(x)
x <- as.factor(x)
res <- matrix(valFalse, n, length(levels(x)) )
res[(1:n) + n*(unclass(x)-1)] <- valTrue
dimnames(res) <- list(names(x), levels(x))

colnames(targets) <- classes
targets
res
}


#' Applies \code{analyzeClassification} row-wise to a matrix.
#'
#' @title Encode a matrix of (decoded) class labels
Expand Down
Binary file modified data/snnsData.RData
Binary file not shown.
1 change: 1 addition & 0 deletions demo/00Index
Expand Up @@ -9,6 +9,7 @@ dlvq_ziff the original SNNS dlvq ziff example, using the RSNNS high-level api (r
eight_elman the original SNNS eight elman example, using the RSNNS high-level api (rsnns)
rbf_sin a rbf network to approximante a a noisy sin function, using the RSNNS high-level api (rsnns)
mlp_iris_tuning training of an mlp for iris, with grid search of the hyper-parameters (rsnns)
mlp_irisSnnsR a mlp for classification of the iris data, using the RSNNS low-level api (SnnsR)
encoderSnnsCLib the original SNNS encoder example, using the RSNNS low-level api (SnnsR), and only functions directly mapped to SnnsCLib functions
art1_lettersSnnsR the original art1 letters example, using the RSNNS low-level api (SnnsR)
art2_tetraSnnsR the original art2 tetra example, using the RSNNS low-level api (SnnsR)
Expand Down
4 changes: 2 additions & 2 deletions demo/eight_elman.R
Expand Up @@ -7,10 +7,10 @@ outputs <- snnsData$eight_016.pat[,outputColumns(snnsData$eight_016.pat)]

par(mfrow=c(1,2))

modelElman <- elman(inputs, outputs, size=8, decay=0.1, maxit=1000)
modelElman <- elman(inputs, outputs, size=8, learnFuncParams=c(0.1), maxit=1000)
modelElman

modelJordan <- jordan(inputs, outputs, size=8, decay=0.1, maxit=1000)
modelJordan <- jordan(inputs, outputs, size=8, learnFuncParams=c(0.1), maxit=1000)
modelJordan

plotIterativeError(modelElman)
Expand Down
57 changes: 57 additions & 0 deletions demo/mlp_irisSnnsR.R
@@ -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)

2 changes: 1 addition & 1 deletion demo/rbf_irisSnnsR.R
Expand Up @@ -63,5 +63,5 @@ predictions <- snnsObject$predictCurrPatSet("output", c(0))
confusionMatrix(outputs,predictions)

snnsObject$saveNet(paste(basePath,"rbf_irisSnnsR.net",sep=""),"rbf_irisSnnsR")
snnsObject$saveNewPatterns(paste(basePath,"rbf_irisSnnsR.pat",sep=""), patset$set_no);
snnsObject$saveNewPatterns(paste(basePath,"rbf_irisSnnsR.pat",sep=""), patset$set_no)

28 changes: 20 additions & 8 deletions inst/CITATION
@@ -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/.")
)

0 comments on commit ecf737f

Please sign in to comment.