Skip to content

Commit

Permalink
var_sel argument to lekprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed Jul 7, 2015
1 parent 8f489ac commit 137e71d
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 32 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: NeuralNetTools
Type: Package
Title: Visualization and Analysis Tools for Neural Networks
Version: 1.3.7
Date: 2015-06-29
Version: 1.3.8
Date: 2015-07-07
Author: Marcus W. Beck [aut, cre]
Maintainer: Marcus W. Beck <[email protected]>
Description: Visualization and analysis tools to aid in the interpretation of
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.1.0): do not edit by hand
# Generated by roxygen2 (4.1.1): do not edit by hand

S3method(garson,mlp)
S3method(garson,nn)
Expand Down
26 changes: 18 additions & 8 deletions R/NeuralNetTools_lek.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#'
#' @param mod_in input object for which an organized model list is desired. The input can be an object of class \code{nnet} or \code{mlp}
#' @param steps numeric value indicating number of observations to evaluate for each explanatory variable from minimum to maximum value, default 100
#' @param var_sel optional chr string of explanatory variables to evaluate, defaults to all
#' @param split_vals numeric vector indicating quantile values at which to hold other explanatory variables constant
#' @param val_out logical value indicating if actual sensitivity values are returned rather than a plot, default \code{FALSE}
#' @param ... arguments passed to other methods
Expand Down Expand Up @@ -93,8 +94,8 @@ lekprofile <- function(mod_in, ...) UseMethod('lekprofile')
#' @export
#'
#' @method lekprofile default
lekprofile.default <- function(mod_in, steps = 100, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){

lekprofile.default <- function(mod_in, steps = 100, var_sel = NULL, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){
##
#sort out exp and resp names based on object type of call to mod_in
#get matrix for exp vars
Expand All @@ -115,6 +116,9 @@ lekprofile.default <- function(mod_in, steps = 100, split_vals = seq(0, 1, by =
}
}

# subset var_sens if var_sel is not empy
if(!is.null(var_sel)) var_sens <- var_sens[var_sens %in% var_sel]

# stop if only one input variable
if(ncol(mat_in) == 1) stop('Lek profile requires greater than one input variable')

Expand Down Expand Up @@ -168,9 +172,9 @@ lekprofile.default <- function(mod_in, steps = 100, split_vals = seq(0, 1, by =
#' @export
#'
#' @method lekprofile nnet
lekprofile.nnet <- function(mod_in,steps = 100, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){
lekprofile.nnet <- function(mod_in, steps = 100, var_sel = NULL, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){

lekprofile.default(mod_in, steps, split_vals, val_out)
lekprofile.default(mod_in, steps, var_sel, split_vals, val_out)

}

Expand All @@ -183,7 +187,7 @@ lekprofile.nnet <- function(mod_in,steps = 100, split_vals = seq(0, 1, by = 0.2)
#' @export
#'
#' @method lekprofile mlp
lekprofile.mlp <- function(mod_in, exp_in, steps = 100, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){
lekprofile.mlp <- function(mod_in, exp_in, var_sel = NULL, steps = 100, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){

##
#sort out exp and resp names based on object type of call to mod_in
Expand All @@ -193,6 +197,9 @@ lekprofile.mlp <- function(mod_in, exp_in, steps = 100, split_vals = seq(0, 1, b
names(mat_in) <- paste0('X', seq(1, mod_in$nInputs))
var_sens <- names(mat_in)

# subset var_sens if var_sel is not empy
if(!is.null(var_sel)) var_sens <- var_sens[var_sens %in% var_sel]

#use 'pred_fun' to get pred vals of response across range of vals for an exp vars
#loops over all explanatory variables of interest and all split values
lek_vals <- sapply(
Expand Down Expand Up @@ -242,7 +249,7 @@ lekprofile.mlp <- function(mod_in, exp_in, steps = 100, split_vals = seq(0, 1, b
#' @export
#'
#' @method lekprofile train
lekprofile.train <- function(mod_in, steps = 100, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){
lekprofile.train <- function(mod_in, steps = 100, var_sel = NULL, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){

# input data, x_names, and y_names
mat_in <- mod_in$trainingData
Expand All @@ -261,6 +268,9 @@ lekprofile.train <- function(mod_in, steps = 100, split_vals = seq(0, 1, by = 0.
resp_name <- y_names
var_sens <- names(mat_in)

# subset var_sens if var_sel is not empy
if(!is.null(var_sel)) var_sens <- var_sens[var_sens %in% var_sel]

#use 'pred_fun' to get pred vals of response across range of vals for an exp vars
#loops over all explanatory variables of interest and all split values
lek_vals <- sapply(
Expand Down Expand Up @@ -310,7 +320,7 @@ lekprofile.train <- function(mod_in, steps = 100, split_vals = seq(0, 1, by = 0.
#' @export
#'
#' @method lekprofile nn
lekprofile.nn <- function(mod_in, steps = 100, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){
lekprofile.nn <- function(mod_in, steps = 100, var_sel = NULL, split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...){

# recreate the model using nnet (no predict method for nn)
moddat <- mod_in$data
Expand Down Expand Up @@ -338,7 +348,7 @@ lekprofile.nn <- function(mod_in, steps = 100, split_vals = seq(0, 1, by = 0.2),
mod_in <- eval(mod_in)

# pass to lekprofile.nnet
lekprofile(mod_in, steps = steps, split_vals = split_vals, val_out = val_out, ...)
lekprofile(mod_in, steps = steps, var_sel = var_sel, split_vals = split_vals, val_out = val_out, ...)

}

Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install.packages('NeuralNetTools')

Please cite this package as follows:

*Beck MW. 2015. NeuralNetTools: Visualization and Analysis Tools for Neural Networks. Version 1.3.2. http://cran.r-project.org/web/packages/NeuralNetTools/*
*Beck MW. 2015. NeuralNetTools: Visualization and Analysis Tools for Neural Networks. Version 1.3.8. http://cran.r-project.org/web/packages/NeuralNetTools/*

### Bug reports

Expand Down
2 changes: 1 addition & 1 deletion README.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h4><em>Marcus W. Beck, <a href="mailto:[email protected]">[email protected]
<div id="citation" class="section level3">
<h3>Citation</h3>
<p>Please cite this package as follows:</p>
<p><em>Beck MW. 2015. NeuralNetTools: Visualization and Analysis Tools for Neural Networks. Version 1.3.2. <a href="http://cran.r-project.org/web/packages/NeuralNetTools/" class="uri">http://cran.r-project.org/web/packages/NeuralNetTools/</a></em></p>
<p><em>Beck MW. 2015. NeuralNetTools: Visualization and Analysis Tools for Neural Networks. Version 1.3.8. <a href="http://cran.r-project.org/web/packages/NeuralNetTools/" class="uri">http://cran.r-project.org/web/packages/NeuralNetTools/</a></em></p>
</div>
<div id="bug-reports" class="section level3">
<h3>Bug reports</h3>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ install.packages('NeuralNetTools')

Please cite this package as follows:

*Beck MW. 2015. NeuralNetTools: Visualization and Analysis Tools for Neural Networks. Version 1.3.2. http://cran.r-project.org/web/packages/NeuralNetTools/*
*Beck MW. 2015. NeuralNetTools: Visualization and Analysis Tools for Neural Networks. Version 1.3.8. http://cran.r-project.org/web/packages/NeuralNetTools/*

### Bug reports

Expand Down
Binary file modified README_files/figure-html/unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-html/unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-html/unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-html/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/garson.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/NeuralNetTools_gar.R
\name{garson}
\alias{garson}
Expand Down
24 changes: 13 additions & 11 deletions man/lekprofile.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/NeuralNetTools_lek.R
\name{lekprofile}
\alias{lekprofile}
Expand All @@ -11,20 +11,20 @@
\usage{
lekprofile(mod_in, ...)
\method{lekprofile}{default}(mod_in, steps = 100, split_vals = seq(0, 1, by
= 0.2), val_out = FALSE, ...)
\method{lekprofile}{default}(mod_in, steps = 100, var_sel = NULL,
split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...)
\method{lekprofile}{nnet}(mod_in, steps = 100, split_vals = seq(0, 1, by =
0.2), val_out = FALSE, ...)
\method{lekprofile}{nnet}(mod_in, steps = 100, var_sel = NULL,
split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...)
\method{lekprofile}{mlp}(mod_in, exp_in, steps = 100, split_vals = seq(0, 1,
by = 0.2), val_out = FALSE, ...)
\method{lekprofile}{mlp}(mod_in, exp_in, var_sel = NULL, steps = 100,
split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...)
\method{lekprofile}{train}(mod_in, steps = 100, split_vals = seq(0, 1, by =
0.2), val_out = FALSE, ...)
\method{lekprofile}{train}(mod_in, steps = 100, var_sel = NULL,
split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...)
\method{lekprofile}{nn}(mod_in, steps = 100, split_vals = seq(0, 1, by =
0.2), val_out = FALSE, ...)
\method{lekprofile}{nn}(mod_in, steps = 100, var_sel = NULL,
split_vals = seq(0, 1, by = 0.2), val_out = FALSE, ...)
}
\arguments{
\item{mod_in}{input object for which an organized model list is desired. The input can be an object of class \code{nnet} or \code{mlp}}
Expand All @@ -33,6 +33,8 @@ lekprofile(mod_in, ...)
\item{steps}{numeric value indicating number of observations to evaluate for each explanatory variable from minimum to maximum value, default 100}
\item{var_sel}{optional chr string of explanatory variables to evaluate, defaults to all}
\item{split_vals}{numeric vector indicating quantile values at which to hold other explanatory variables constant}
\item{val_out}{logical value indicating if actual sensitivity values are returned rather than a plot, default \code{FALSE}}
Expand Down
2 changes: 1 addition & 1 deletion man/neuraldat.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/NeuralNetTools_neuraldat.R
\docType{data}
\name{neuraldat}
Expand Down
2 changes: 1 addition & 1 deletion man/neuralskips.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/NeuralNetTools_utils.R
\name{neuralskips}
\alias{neuralskips}
Expand Down
2 changes: 1 addition & 1 deletion man/neuralweights.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/NeuralNetTools_utils.R
\name{neuralweights}
\alias{neuralweights}
Expand Down
2 changes: 1 addition & 1 deletion man/olden.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/NeuralNetTools_old.R
\name{olden}
\alias{olden}
Expand Down
2 changes: 1 addition & 1 deletion man/plotnet.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/NeuralNetTools_plot.R
\name{plotnet}
\alias{plotnet}
Expand Down
2 changes: 1 addition & 1 deletion man/pred_sens.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Generated by roxygen2 (4.1.0): do not edit by hand
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/NeuralNetTools_utils.R
\name{pred_sens}
\alias{pred_sens}
Expand Down

0 comments on commit 137e71d

Please sign in to comment.