Type: Package
Title: Look-Up Tables using S4
Version: 0.1
Date: 2015-08-17
Maintainer: Enzo Jia <enzo.jia@gmail.com>
Description: Fits look-up tables by filling entries with the mean or median values of observations fall in partitions of the feature space. Partitions can be determined by user of the package using input argument feature.boundaries, and dimensions of the feature space can be any combination of continuous and categorical features provided by the data set. A Predict function directly fetches corresponding entry value, and a default value is defined as the mean or median of all available observations. The table and other components are represented using the S4 class lookupTable.
License: MIT + file LICENSE
LazyData: TRUE
Imports: dplyr, methods
Depends: data.table
Suggests: testthat
NeedsCompilation: no
Packaged: 2015-08-27 13:26:20 UTC; mm87727
Author: Enzo Jia [aut, cre], Marc Maier [aut]
Repository: CRAN
Date/Publication: 2015-08-28 01:21:23

Initialize and construct a lookupTable object

Description

Initialize and construct a lookupTable object

Usage

## S4 method for signature 'lookupTable'
initialize(.Object, df.input, response,
  feature.boundaries, features.con = character(0),
  features.cat = character(0), fill.method = "mean")

Arguments

.Object

the prototype object

df.input

training data set containing columns with names found in features.con and features.cat vectors

response

name of the response variable

feature.boundaries

a list of thresholds for each continuous feature (names contained in feature.con) to construct bins. Should use -Inf and Inf as the first and last values, respectively.

features.con

a vector of continuous feature names

features.cat

a vector of categorical feature names

fill.method

the method to fill entries of the table ('mean' or 'median')

Value

A lookupTable object with a table trained with df.input data


An S4 class that defines the look-up table and all other components required for prediction using this table.

Description

An S4 class that defines the look-up table and all other components required for prediction using this table.

Slots

table

the look-up table with entries to be retrieved as prediction results

feature.con

a vector of continuous feature names

feature.cat

a vector of categorical feature names

feature.boundaries

a list of boundaries for each input feature (inferred during construction from input data)

response

the name of the response variable for the look-up table

default

the default value for cells corresponding to a missing combination of input values

response.categories

sequence of all categories (order-dependent) for the response variable, if it's categorical


Predictions from a look-up table

Description

predict method for lookupTable objects

Usage

## S3 method for class 'lookupTable'
predict(object, newdata, newparams = NULL, ...)

Arguments

object

a fitted lookupTable object

newdata

data.frame from which to evaluate predictions

newparams

new parameters to use in evaluating predictions

...

optional additional parameters. None are used at present.

Value

a numeric vector of predicted values

Examples

df.input <- cars
response <- 'dist'
feature.boundaries <- list(c(-Inf, 5, 10, 15, 20, 25, Inf))
features.con <- c('speed')
dist.table <- lookupTable(df.input, response, feature.boundaries, features.con)
df.test <- data.frame(speed = c(2, 23, 41, 5, 9, 8))
predict(dist.table, df.test)