Skip to content

Commit

Permalink
Initial documentation for hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertzk committed Aug 2, 2015
1 parent 091a6c4 commit 3ffca24
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 4 deletions.
45 changes: 45 additions & 0 deletions R/hooks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#' Add a hook to a tundraContainer.
#'
#' Hooks are useful for defining additional checks that should be
#' performed prior to and during training and prediction. For example,
#' one might want to issue a warning if the user is predicting on
#' rows that were used for training, or a sanity check might be
#' present prior to training to ensure a dependent variable is present.
#'
#' The following hooks are available.
#'
#' \enumerate{
#' \item{train_pre_munge}{This hook runs during a call to the
#' container's \code{train} method, just prior to invoking the
#' \code{munge_procedure} to clean up the dataset. It could be
#' useful for defining pre-conditions on the dataset to ensure
#' it can be munged successfully.}
#' \item{train_post_munge}{This hook runs during a call to the
#' container's \code{train} method, just after invoking the
#' \code{munge_procedure} to clean up the dataset. It could be
#' useful for defining post-conditions on the dataset to ensure
#' it was munged successfully.}
#' \item{train_finalize}{This hook runs just after the \code{train}
#' method calls the \code{train_function}. It could be used to
#' verify presence or validate properties of the trained model.}
#' \item{predict_pre_munge}{This hook runs during a call to the
#' container's \code{predict} method, just prior to invoking the
#' \code{munge_procedure} to clean up the dataset. It could be
#' useful for defining pre-conditions on the dataset to ensure
#' it can be munged successfully.}
#' \item{predict_post_munge}{This hook runs during a call to the
#' container's \code{predict} method, just after invoking the
#' \code{munge_procedure} to clean up the dataset. It could be
#' useful for defining post-conditions on the dataset to ensure
#' it was munged successfully.}
#' }
#'
#' Each hook will be provided the \code{tundraContainer} as input
#' (unless it has no arguments, in which case it will simply be called).
#'
#' @param hook_name character. The hook to run. Must be one of the available
#' hooks.
run_hooks <- function(hook_name) {

}

3 changes: 0 additions & 3 deletions R/tundraContainer-run_hooks.R

This file was deleted.

52 changes: 52 additions & 0 deletions man/run_hooks.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/hooks.R
\name{run_hooks}
\alias{run_hooks}
\title{Add a hook to a tundraContainer.}
\usage{
run_hooks(hook_name)
}
\arguments{
\item{hook_name}{character. The hook to run. Must be one of the available
hooks.}
}
\description{
Hooks are useful for defining additional checks that should be
performed prior to and during training and prediction. For example,
one might want to issue a warning if the user is predicting on
rows that were used for training, or a sanity check might be
present prior to training to ensure a dependent variable is present.
}
\details{
The following hooks are available.

\enumerate{
\item{train_pre_munge}{This hook runs during a call to the
container's \code{train} method, just prior to invoking the
\code{munge_procedure} to clean up the dataset. It could be
useful for defining pre-conditions on the dataset to ensure
it can be munged successfully.}
\item{train_post_munge}{This hook runs during a call to the
container's \code{train} method, just after invoking the
\code{munge_procedure} to clean up the dataset. It could be
useful for defining post-conditions on the dataset to ensure
it was munged successfully.}
\item{train_finalize}{This hook runs just after the \code{train}
method calls the \code{train_function}. It could be used to
verify presence or validate properties of the trained model.}
\item{predict_pre_munge}{This hook runs during a call to the
container's \code{predict} method, just prior to invoking the
\code{munge_procedure} to clean up the dataset. It could be
useful for defining pre-conditions on the dataset to ensure
it can be munged successfully.}
\item{predict_post_munge}{This hook runs during a call to the
container's \code{predict} method, just after invoking the
\code{munge_procedure} to clean up the dataset. It could be
useful for defining post-conditions on the dataset to ensure
it was munged successfully.}
}

Each hook will be provided the \code{tundraContainer} as input
(unless it has no arguments, in which case it will simply be called).
}

2 changes: 1 addition & 1 deletion man/tundraContainer.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\name{tundraContainer}
\alias{tundraContainer}
\title{A standard container format for classifiers developed in R.}
\format{\preformatted{Class 'R6ClassGenerator' <environment: 0x10cd07d50>
\format{\preformatted{Class 'R6ClassGenerator' <environment: 0x10e349b50>
- attr(*, "name")= chr "tundraContainer_generator"
}}
\usage{
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-hooks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
context("hooks")

0 comments on commit 3ffca24

Please sign in to comment.