cat2cat_ml_run | R Documentation |
ml and mappings arguments in cat2cat
function can be used to run cross validation across all groups in ml data.
cat2cat_ml_run(mappings, ml, ...)
## S3 method for class 'cat2cat_ml_run'
print(x, ...)
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 |
argument x invisibly
cat2cat
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.