cat2cat_ml_run: Function to check cat2cat ml models performance

View source: R/cat2cat_ml.R

cat2cat_ml_runR Documentation

Function to check cat2cat ml models performance

Description

ml and mappings arguments in cat2cat function can be used to run cross validation across all groups in ml data.

Usage

cat2cat_ml_run(mappings, ml, ...)

## S3 method for class 'cat2cat_ml_run'
print(x, ...)

Arguments

mappings

'named list' with 3 fields 'trans', 'direction' and optional 'freqs_df'.

ml

'named list' (optional) with up to 5 fields 'data', 'cat_var', 'method', 'features' and optional 'args'.

...

other arguments

x

cat2cat_ml_run instance created with cat2cat_ml_run function.

Value

argument x invisibly

See Also

cat2cat

Examples

## Not run: 
library("cat2cat")
data("occup", package = "cat2cat")
data("trans", package = "cat2cat")

occup_2006 <- occup[occup$year == 2006, ]
occup_2008 <- occup[occup$year == 2008, ]
occup_2010 <- occup[occup$year == 2010, ]
occup_2012 <- occup[occup$year == 2012, ]

library("caret")
ml_setup <- list(
  data = rbind(occup_2010, occup_2012),
  cat_var = "code",
  method = c("knn", "rf", "lda"),
  features = c("age", "sex", "edu", "exp", "parttime", "salary"),
  args = list(k = 10, ntree = 50)
)
data <- list(
  old = occup_2008, new = occup_2010,
  cat_var_old = "code", cat_var_new = "code", time_var = "year"
)
mappings <- list(trans = trans, direction = "backward")
res <- cat2cat_ml_run(mappings, ml_setup, test_prop = 0.2)
res

## End(Not run)


Polkas/catTOcat documentation built on Jan. 26, 2024, 7:10 a.m.