R Under development (unstable) (2025-12-15 r89175 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > suppressMessages(library("wsrf")) > suppressMessages(library("randomForest")) > > # prepare parameters > ds <- iris > target <- "Species" > vars <- names(ds) > if (sum(is.na(ds[vars]))) ds[vars] <- na.roughfix(ds[vars]) > ds[target] <- as.factor(ds[[target]]) > (form <- as.formula(paste(target, "~ ."))) Species ~ . > set.seed(500) > length(train <- sample(nrow(ds), 0.7*nrow(ds))) [1] 105 > length(test <- setdiff(seq_len(nrow(ds)), train)) [1] 45 > > > # build model > model.wsrf <- wsrf(form, data=ds[train, vars], parallel=FALSE) > model.wsrf.nw <- wsrf(form, data=ds[train, vars], weights=FALSE, parallel=FALSE) > model.wsrf.nw.vi <- wsrf(form, data=ds[train, vars], weights=FALSE, importance=TRUE, parallel=FALSE) > model.subset <- subset.wsrf(model.wsrf, 1:200) > model.combine <- combine.wsrf(model.wsrf, model.wsrf.nw) > > > # evaluate > > # Note: > # 32bit system and 64bit system will have different results, however, > # if random seed is fixed, the same results will be presented in the > # same system. > > cl <- predict(model.wsrf, newdata=ds[test, vars], type="class")$class > cl.nw <- predict(model.wsrf.nw, newdata=ds[test, vars], type="class")$class > cl.subset <- predict(model.subset, newdata=ds[test, vars], type="class")$class > cl.combine <- predict(model.combine, newdata=ds[test, vars], type="class")$class > > proc.time() user system elapsed 0.39 0.06 0.42