R Under development (unstable) (2026-01-26 r89334 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 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. > library(fru) > > data(iris) > set.seed(17) > > # Basic tests > > fru(iris[,-5],iris[,5],trees=5000,importance=TRUE,forest=TRUE,oob=TRUE,threads=2)->model > imp<-importance(model) > op<-predict(model,threads=2) > pp<-predict(model,iris[,-5],threads=2) > > stopifnot(mean(op==iris[,5])>0.9) > stopifnot(all(rank(imp)==c(2,1,4,3))) > stopifnot(mean(pp==iris[,5])>0.9) > > print(model) Fru forest of 5000 trees OOB True setosa versicolor virginica setosa 50 0 0 versicolor 0 47 3 virginica 0 3 47 OOB error 4.00% Forest available Importance available > > # Verify serialisation > > reserialise<-function(x){ + cc<-rawConnection(raw(),"w+") + serialize(x,connection=cc) + stream<-rawConnectionValue(cc) + ans<-unserialize(rawConnection(stream)) + ans + } > > solidify(model) > reserialise(model)->model_copy > > imp2<-importance(model_copy) > op2<-predict(model_copy,thread=2) > pp2<-predict(model_copy,iris[,-5],thread=2) > > stopifnot(identical(imp,imp2)) > stopifnot(identical(op,op2)) > stopifnot(identical(pp,pp2)) > > # Run finalisation > > rm(model) > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 329947 17.7 629171 33.7 555797 29.7 Vcells 1236916 9.5 8388608 64.0 2791208 21.3 Warning messages: 1: In .Internal(gc(verbose, reset, full)) : closing unused connection 4 (stream) 2: In .Internal(gc(verbose, reset, full)) : closing unused connection 3 (raw()) > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 330815 17.7 629171 33.7 555797 29.7 Vcells 730239 5.6 8388608 64.0 2791208 21.3 > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 330815 17.7 629171 33.7 555797 29.7 Vcells 730239 5.6 8388608 64.0 2791208 21.3 > > > # Run regression > > fru(iris[,-2],iris[,2],trees=500,importance=TRUE,forest=TRUE,oob=TRUE,threads=2)->model > predict(model,iris[,5:1])->pred > stopifnot(cor(pred,iris[,2])>0.9) > > # Check unwinding > > poisoned_iris<-iris > poisoned_iris[,3]<-poisoned_iris[,3]*(1+2i) > > try(fru(poisoned_iris[,-2],poisoned_iris[,2],threads=2))->exp_err thread '' (51840) panicked at src\lib.rs:123:30: Unsupported data type in input note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Error in fru(poisoned_iris[, -2], poisoned_iris[, 2], threads = 2) : Computational kernel of fru has thrown a panic; input data was likely invalid > stopifnot(inherits(exp_err,"try-error")) > > > > proc.time() user system elapsed 0.45 0.06 0.37