Learn R Programming

mixvlmc (version 0.2.1)

trim.covlmc: Trim a COVLMC

Description

This function returns a trimmed COVLMC from which cached data have been removed.

Usage

# S3 method for covlmc
trim(ct, keep_model = FALSE, ...)

Value

a trimmed context tree.

Arguments

ct

a context tree.

keep_model

specifies whether to keep the internal models (or not)

...

additional arguments for the trim function.

Details

Called with keep_model set to FALSE (default case), the trimming is maximal and reduces further usability of the model. In particular loglikelihood.covlmc() cannot be used for new data, contexts.covlmc() do not support model extraction, and simulate.covlmc(), metrics.covlmc() and prune.covlmc() cannot be used at all.

Called with keep_model set to TRUE, the trimming process is less complete. In particular internal models are simplified using butcher::butcher() and some additional minor reductions. This saves less memory but enables the use of loglikelihood.covlmc() for new data as well as the use of simulate.covlmc().

See Also

tune_covlmc()

Examples

Run this code
pc <- powerconsumption[powerconsumption$week %in% 5:7, ]
dts <- cut(pc$active_power, breaks = c(0, quantile(pc$active_power, probs = c(0.5, 1))))
dts_cov <- data.frame(day_night = (pc$hour >= 7 & pc$hour <= 17))
m_cov <- covlmc(dts, dts_cov, min_size = 10, keep_data = TRUE)
print(object.size(m_cov), units = "Mb")
t_m_cov_model <- trim(m_cov, keep_model = TRUE)
print(object.size(t_m_cov_model), units = "Mb")
t_m_cov <- trim(m_cov)
print(object.size(t_m_cov), units = "Mb")

Run the code above in your browser using DataLab