Type: Package
Title: Purge Training Data from Models
Version: 0.2.1
Date: 2015-10-29
Maintainer: Marc Maier <mmaier@massmutual.com>
Description: Enables the removal of training data from fitted R models while retaining predict functionality. The purged models are more portable as their memory footprints do not scale with the training sample size.
License: MIT + file LICENSE
LazyData: TRUE
Imports: methods
Suggests: testthat, survival, lme4 (≥ 1.1-8), ranger, randomForest, rpart
NeedsCompilation: no
Packaged: 2017-02-12 02:08:55 UTC; mm90357
Author: Marc Maier [cre], Chaoqun Jia [ctb], MassMutual Advanced Analytics [aut] (http://datascience.massmutual.com)
RoxygenNote: 6.0.1
Repository: CRAN
Date/Publication: 2017-02-12 08:31:10

Purge training data from a model

Description

Most R model implementations store the training data within the fitted object, often many times. It can be useful to remove the embedded data for portability, especially if the only required functionality is to predict on new data.

Usage

purge(model)

## Default S3 method:
purge(model)

## S3 method for class 'glm'
purge(model)

## S3 method for class 'lm'
purge(model)

## S3 method for class 'merMod'
purge(model)

## S3 method for class 'glmerMod'
purge(model)

## S3 method for class 'rpart'
purge(model)

## S3 method for class 'randomForest'
purge(model)

## S3 method for class 'ranger'
purge(model)

## S3 method for class 'coxph'
purge(model)

Arguments

model

A fitted R model object

Value

A fitted R model object, purged of its training data, but retaining its predict functionality on new data

Methods (by class)

Examples

x <- rnorm(1000)
y <- x + rnorm(1000)
unpurged.model <- lm(y ~ x)
purged.model <- purge(unpurged.model)
object.size(unpurged.model)
object.size(purged.model)