Skip to content

Commit

Permalink
Merge 1ce16d3 into 2132ed1
Browse files Browse the repository at this point in the history
  • Loading branch information
robertzk committed Jan 1, 2016
2 parents 2132ed1 + 1ce16d3 commit e0c8fb6
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,7 @@ install:
- ./travis-tool.sh install_deps
- ./travis-tool.sh install_r testthat
- ./travis-tool.sh install_github syberia/stagerunner robertzk/Ramd
- ./travis-tool.sh install_github robertzk/statsUtils robertzk/mungebits
- ./travis-tool.sh install_github robertzk/statsUtils robertzk/mungebits2 robertzk/mungebits
- ./travis-tool.sh install_github robertzk/syberiaMungebits robertzk/testthatsomemore
- "./travis-tool.sh install_github jimhester/covr"
script: ./travis-tool.sh run_tests
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,17 @@
# Version 0.2.3.9000

* Start development version and use mungebits2 package throughout.

# Version 0.2.3

* The `munge_procedure` passed to a `tundraContainer` can now be a stageRunner,
in preparation for hierarchical munging in the mungebits2 package.

# Version 0.2.2

* tundraContainer objects can now add pre-munge and post-munge hooks - functions
that will be executed before and after munging when the `train` or
`predict` methods are called. You can add a hook using
`container$add_hook('train_pre_munge', function() { ... })`. Note these functions
can modify the tundraContainer's internals, like `input` or `output`.

5 changes: 3 additions & 2 deletions DESCRIPTION
Expand Up @@ -4,7 +4,7 @@ Description: Tundra provides a standardized container format for classifiers
developed in R. This allows easier deployment by keeping both the data
preparation procedure and the statistics in one place with an easy
interface.
Version: 0.3.0
Version: 0.3.0.9000
Author: Robert Krzyzanowski <technoguyrob@gmail.com>
Maintainer: Robert Krzyzanowski <technoguyrob@gmail.com>
Authors@R: c(person("Robert", "Krzyzanowski",
Expand All @@ -13,12 +13,13 @@ Depends:
R (>= 3.0.1)
Imports:
crayon,
mungebits,
R6,
stagerunner
License: MIT + file LICENSE
LazyData: true
Suggests:
mungebits2,
testthat,
testthatsomemore
Roxygen: list(wrap = FALSE)
RoxygenNote: 5.0.1
2 changes: 1 addition & 1 deletion NAMESPACE
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.1.1): do not edit by hand
# Generated by roxygen2: do not edit by hand

S3method(print,tundraContainer)
S3method(summary,tundraContainer)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
@@ -1,7 +1,7 @@
# Version 0.2.3

* The `munge_procedure` passed to a `tundraContainer` can now be a stageRunner,
in preparation for hierarchical munging in the mungebits package.
in preparation for hierarchical munging in the mungebits2 package.

# Version 0.2.2

Expand Down
2 changes: 1 addition & 1 deletion R/package.tundra.R
Expand Up @@ -25,7 +25,7 @@
#' a \code{train} method.}
#' }
#'
#' The former is provided by the \href{https://github.com/robertzk/mungebits22}{mungebits2}
#' The former is provided by the \href{https://github.com/syberia/mungebits2}{mungebits2}
#' package, while the latter is fully customizable to any R function. This
#' approach allows arbitrary data preparation and statistical methods, unlike
#' attempts such as PMML (Predictive Modeling Markup Language) which constrain
Expand Down
2 changes: 1 addition & 1 deletion R/tundraContainer-initialize.R
Expand Up @@ -12,7 +12,7 @@
#' output (such as whether to return a probabilistic or absolute
#' value).
#' @param munge_procedure list. A list of trained
#' \code{\link[mungebits]{mungepiece}}s to apply to data sets
#' \code{\link[mungebits2]{mungepiece}}s to apply to data sets
#' during prediction.
#' @param default_args list. A list of default arguments to provide to
#' the second argument of the \code{train_function}. The additional
Expand Down
2 changes: 1 addition & 1 deletion R/tundraContainer-train.R
Expand Up @@ -55,7 +55,7 @@ munge <- function(dataframe, munge_procedure, verbose) {
if (isTRUE(verbose)) {
capture.output(Recall(dataframe, munge_procedure, FALSE))
} else {
mungebits::munge(dataframe, munge_procedure)
mungebits2::munge(dataframe, munge_procedure)
}
}

2 changes: 1 addition & 1 deletion R/tundraContainer.R
Expand Up @@ -22,7 +22,7 @@ tundraContainer <- R6::R6Class("tundraContainer",
add_hook = add_hook,

munge = function(dataframe, steps = TRUE) {
mungebits::munge(dataframe, munge_procedure[steps])
mungebits2::munge(dataframe, munge_procedure[steps])
},
show = function() {
cat("A tundraContainer of type ", sQuote(self$.keyword), "\n")
Expand Down
10 changes: 5 additions & 5 deletions R/tundra_container.r
Expand Up @@ -49,12 +49,12 @@ tundra_container <- setRefClass('tundraContainer', #define reference classes to
.run_hooks('train_pre_munge')

if (length(munge_procedure) > 0 && identical(munge, TRUE)) {
require(mungebits)
require(mungebits2)
triggers <- unlist(lapply(munge_procedure,
function(x) inherits(x, 'trigger')))

(if (!verbose) capture.output else function(...) eval.parent(...))(
dataframe <- mungebits::munge(dataframe, munge_procedure)) # Apply munge_procedure to dataframe
dataframe <- mungebits2::munge(dataframe, munge_procedure)) # Apply munge_procedure to dataframe

# Store trained munge_procedure
munge_procedure <<- attr(dataframe, 'mungepieces')[!triggers]
Expand Down Expand Up @@ -90,10 +90,10 @@ tundra_container <- setRefClass('tundraContainer', #define reference classes to
.run_hooks('predict_pre_munge')

if (length(munge_procedure) > 0 && identical(munge, TRUE)) {
require(mungebits)
require(mungebits2)
initial_nrow <- nrow(dataframe)
(if (!verbose) capture.output else function(...) eval.parent(...))(
dataframe <- mungebits::munge(dataframe, munge_procedure)) # Apply munge_procedure to dataframe
dataframe <- mungebits2::munge(dataframe, munge_procedure)) # Apply munge_procedure to dataframe
if (nrow(dataframe) != initial_nrow)
warning(paste("Some rows were removed during data preparation.",
"Predictions will not match input dataframe."))
Expand All @@ -119,7 +119,7 @@ tundra_container <- setRefClass('tundraContainer', #define reference classes to
},

munge = function(dataframe, steps = TRUE) {
mungebits::munge(dataframe, munge_procedure[steps])
mungebits2::munge(dataframe, munge_procedure[steps])
},

show = function() {
Expand Down
2 changes: 1 addition & 1 deletion man/call_with.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/hooks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/initialize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/list_merge.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/predict.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/train.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/tundra.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions man/tundraContainer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions man/tundra_container.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tests/testthat/test-hooks.R
Expand Up @@ -3,10 +3,11 @@ context("hooks")
let(container, tundraContainer$new("foo"))
let(container_with_munge_side_effect, function(env) {
force(env)
mb <- mungebits:::mungebit(function(data) {
mb <- mungebits2::mungebit$new(function(data) {
env$effect <- c(env$effect, "mungebit")
data
})
mp <- mungebits:::mungepiece(mb)
mp <- mungebits2::mungepiece$new(mb)
tundraContainer$new("foo", munge_procedure = list(mp))
})

Expand Down

0 comments on commit e0c8fb6

Please sign in to comment.