Skip to content

Commit

Permalink
fixes with submission - namespace is correct, examples are shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed Nov 30, 2015
1 parent edd22e0 commit f2e0c22
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 33 deletions.
13 changes: 13 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ import(nnet)
import(reshape2)
import(scales)
import(tidyr)
importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(graphics,points)
importFrom(graphics,segments)
importFrom(graphics,text)
importFrom(stats,coef)
importFrom(stats,formula)
importFrom(stats,kmeans)
importFrom(stats,model.frame)
importFrom(stats,predict)
importFrom(stats,quantile)
importFrom(stats,terms)
importFrom(utils,capture.output)
5 changes: 2 additions & 3 deletions R/NeuralNetTools_gar.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#'
#' garson(mod)
#'
#' \dontrun{
#' ## using RSNNS, no bias layers
#'
#' library(RSNNS)
Expand All @@ -76,15 +77,12 @@
#'
#' ## using caret
#'
#' \dontrun{
#' library(caret)
#'
#' mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)
#'
#' garson(mod)
#'
#' }
#'
#' ## modify the plot using ggplot2 syntax
#' library(ggplot2)
#'
Expand All @@ -95,6 +93,7 @@
#' scale_y_continuous('Rel. Importance', limits = c(-1, 1)) +
#' scale_fill_gradientn(colours = cols) +
#' scale_colour_gradientn(colours = cols)
#'}
garson <- function(mod_in, ...) UseMethod('garson')

#' @rdname garson
Expand Down
5 changes: 2 additions & 3 deletions R/NeuralNetTools_lek.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#'
#' lekprofile(mod)
#'
#' \dontrun{
#' ## using RSNNS, no bias layers
#'
#' library(RSNNS)
Expand Down Expand Up @@ -76,15 +77,12 @@
#'
#' ## using caret
#'
#' \dontrun{
#' library(caret)
#'
#' mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)
#'
#' lekprofile(mod)
#'
#' }
#'
#' ## group by clusters instead of sequencing by quantiles
#'
#' mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5)
Expand All @@ -98,6 +96,7 @@
#' names(group_vals) <- names(group_vals)
#'
#' lekprofile(mod, group_vals = group_vals, xsel = 'X3')
#' }
lekprofile <- function(mod_in, ...) UseMethod('lekprofile')

#' @rdname lekprofile
Expand Down
7 changes: 3 additions & 4 deletions R/NeuralNetTools_old.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#'
#' olden(mod)
#'
#' \dontrun{
#' ## View the difference for a model w/ skip layers
#'
#' set.seed(123)
Expand Down Expand Up @@ -82,23 +83,21 @@
#' olden(mod)
#'
#' ## using caret
#'
#' \dontrun{
#'
#' library(caret)
#'
#' mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)
#'
#' olden(mod)
#'
#' }
#'
#' ## multiple hidden layers
#'
#' x <- neuraldat[, c('X1', 'X2', 'X3')]
#' y <- neuraldat[, 'Y1']
#' mod <- mlp(x, y, size = c(5, 7, 6), linOut = TRUE)
#'
#' olden(mod)
#' }
olden <- function(mod_in, ...) UseMethod('olden')

#' @rdname olden
Expand Down
6 changes: 2 additions & 4 deletions R/NeuralNetTools_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#'
#' plotnet(mod, skip = TRUE)
#'
#' \dontrun{
#' ## using RSNNS, no bias layers
#'
#' library(RSNNS)
Expand All @@ -75,7 +76,6 @@
#'
#' plotnet(mod)
#'
#' \dontrun{
#' # pruned model using code from RSSNS pruning demo
#' pruneFuncParams <- list(max_pr_error_increase = 10.0, pr_accepted_error = 1.0,
#' no_of_pr_retrain_cycles = 1000, min_error_to_stop = 0.01, init_matrix_value = 1e-6,
Expand All @@ -85,7 +85,6 @@
#'
#' plotnet(mod)
#' plotnet(mod, prune_col = 'lightblue')
#' }
#'
#' ## using neuralnet
#'
Expand All @@ -97,13 +96,11 @@
#'
#' ## using caret
#'
#' \dontrun{
#' library(caret)
#'
#' mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)
#'
#' plotnet(mod)
#' }
#'
#' ## a more complicated network with categorical response
#' AND <- c(rep(0, 7), 1)
Expand Down Expand Up @@ -133,6 +130,7 @@
#' cols <- colorRampPalette(c('lightgreen', 'darkgreen'))(3)[rank(rel_imp)]
#'
#' plotnet(mod, circle_col = list(cols, 'lightblue'))
#' }
plotnet <- function(mod_in, ...) UseMethod('plotnet')

#' @rdname plotnet
Expand Down
10 changes: 7 additions & 3 deletions R/NeuralNetTools_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#'
#' neuralweights(mod)
#'
#' \dontrun{
#' ## using RSNNS, no bias layers
#'
#' library(RSNNS)
Expand All @@ -43,7 +44,6 @@
#'
#' neuralweights(mod)
#'
#' \dontrun{
#' # pruned model using code from RSSNS pruning demo
#' pruneFuncParams <- list(max_pr_error_increase = 10.0, pr_accepted_error = 1.0,
#' no_of_pr_retrain_cycles = 1000, min_error_to_stop = 0.01, init_matrix_value = 1e-6,
Expand All @@ -53,15 +53,14 @@
#'
#' neuralweights(mod)
#'
#' }
#'
#' ## using neuralnet
#'
#' library(neuralnet)
#'
#' mod <- neuralnet(Y1 ~ X1 + X2 + X3, data = neuraldat, hidden = 5)
#'
#' neuralweights(mod)
#' }
neuralweights <- function(mod_in, ...) UseMethod('neuralweights')

#' @rdname neuralweights
Expand Down Expand Up @@ -724,3 +723,8 @@ lekgrps <- function(grps){
return(p)

}

#' @importFrom graphics par plot points segments text
#' @importFrom stats coef formula kmeans model.frame predict quantile terms
#' @importFrom utils capture.output
NULL
19 changes: 19 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## Resubmission
This is a resubmission. In this version I have removed the NOTE by adding the following to the NAMESPACE:

importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(graphics,points)
importFrom(graphics,segments)
importFrom(graphics,text)
importFrom(stats,coef)
importFrom(stats,formula)
importFrom(stats,kmeans)
importFrom(stats,model.frame)
importFrom(stats,predict)
importFrom(stats,quantile)
importFrom(stats,terms)
importFrom(utils,capture.output)

I have also reduced all examples in the documentation to run in less than five seconds.

## Test environments
* local Windows 7 install, R 3.2.2
* local Windows 7 install, Current r-devel (2015-11-30 r69717)
Expand Down
5 changes: 2 additions & 3 deletions man/garson.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5)
garson(mod)
\dontrun{
## using RSNNS, no bias layers
library(RSNNS)
Expand All @@ -96,15 +97,12 @@ garson(mod)
## using caret
\dontrun{
library(caret)
mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)
garson(mod)
}
## modify the plot using ggplot2 syntax
library(ggplot2)
Expand All @@ -116,6 +114,7 @@ garson(mod) +
scale_fill_gradientn(colours = cols) +
scale_colour_gradientn(colours = cols)
}
}
\references{
Garson, G.D. 1991. Interpreting neural network connection weights. Artificial Intelligence Expert. 6(4):46-51.
Expand Down
5 changes: 2 additions & 3 deletions man/lekprofile.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5)

lekprofile(mod)

\dontrun{
## using RSNNS, no bias layers

library(RSNNS)
Expand Down Expand Up @@ -98,15 +99,12 @@ lekprofile(mod)

## using caret

\dontrun{
library(caret)

mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)

lekprofile(mod)

}

## group by clusters instead of sequencing by quantiles

mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5)
Expand All @@ -121,6 +119,7 @@ names(group_vals) <- names(group_vals)

lekprofile(mod, group_vals = group_vals, xsel = 'X3')
}
}
\references{
Lek, S., Delacoste, M., Baran, P., Dimopoulos, I., Lauga, J., Aulagnier, S. 1996. Application of neural networks to modelling nonlinear relationships in Ecology. Ecological Modelling. 90:39-52.

Expand Down
5 changes: 2 additions & 3 deletions man/neuralweights.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5, linout = TRUE)

neuralweights(mod)

\dontrun{
## using RSNNS, no bias layers

library(RSNNS)
Expand All @@ -67,7 +68,6 @@ mod <- mlp(x, y, size = 5, linOut = TRUE)

neuralweights(mod)

\dontrun{
# pruned model using code from RSSNS pruning demo
pruneFuncParams <- list(max_pr_error_increase = 10.0, pr_accepted_error = 1.0,
no_of_pr_retrain_cycles = 1000, min_error_to_stop = 0.01, init_matrix_value = 1e-6,
Expand All @@ -77,8 +77,6 @@ mod <- mlp(x, y, size = 5, pruneFunc = "OptimalBrainSurgeon",

neuralweights(mod)

}

## using neuralnet

library(neuralnet)
Expand All @@ -87,4 +85,5 @@ mod <- neuralnet(Y1 ~ X1 + X2 + X3, data = neuraldat, hidden = 5)

neuralweights(mod)
}
}

5 changes: 2 additions & 3 deletions man/olden.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5)

olden(mod)

\dontrun{
## View the difference for a model w/ skip layers

set.seed(123)
Expand Down Expand Up @@ -106,15 +107,12 @@ olden(mod)

## using caret

\dontrun{
library(caret)

mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)

olden(mod)

}

## multiple hidden layers

x <- neuraldat[, c('X1', 'X2', 'X3')]
Expand All @@ -123,6 +121,7 @@ mod <- mlp(x, y, size = c(5, 7, 6), linOut = TRUE)

olden(mod)
}
}
\references{
Garson, G.D. 1991. Interpreting neural network connection weights. Artificial Intelligence Expert. 6(4):46-51.

Expand Down
6 changes: 2 additions & 4 deletions man/plotnet.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5, skip = TRUE)

plotnet(mod, skip = TRUE)

\dontrun{
## using RSNNS, no bias layers

library(RSNNS)
Expand All @@ -129,7 +130,6 @@ mod <- mlp(x, y, size = 5)

plotnet(mod)

\dontrun{
# pruned model using code from RSSNS pruning demo
pruneFuncParams <- list(max_pr_error_increase = 10.0, pr_accepted_error = 1.0,
no_of_pr_retrain_cycles = 1000, min_error_to_stop = 0.01, init_matrix_value = 1e-6,
Expand All @@ -139,7 +139,6 @@ mod <- mlp(x, y, size = 5, pruneFunc = "OptimalBrainSurgeon",

plotnet(mod)
plotnet(mod, prune_col = 'lightblue')
}

## using neuralnet

Expand All @@ -151,13 +150,11 @@ plotnet(mod)

## using caret

\dontrun{
library(caret)

mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)

plotnet(mod)
}

## a more complicated network with categorical response
AND <- c(rep(0, 7), 1)
Expand Down Expand Up @@ -188,6 +185,7 @@ cols <- colorRampPalette(c('lightgreen', 'darkgreen'))(3)[rank(rel_imp)]

plotnet(mod, circle_col = list(cols, 'lightblue'))
}
}
\references{
Ozesmi, S.L., Ozesmi, U. 1999. An artificial neural network approach to spatial habitat modeling with interspecific interaction. Ecological Modelling. 116:15-31.
}
Expand Down

0 comments on commit f2e0c22

Please sign in to comment.