plot_cross_appl: plot_cross_appl

View source: R/ranger_crossRF_plot_util.R

plot_cross_applR Documentation

plot_cross_appl

Description

The heatmap indicating ML performance (e.g., MAE) in the self-validation and cross-applications.

Usage

plot_cross_appl(
  cross_appl_res,
  metric = "MAE",
  outdir = NULL,
  plot_width = 8,
  plot_height = 7
)

Arguments

cross_appl_res

The output object from rf_clf.cross_appl or rf_reg.cross_appl.

metric

The classification performance metric applied.

outdir

The outputh directory, default is NULL.

plot_width

The width (inches) of heatmap

plot_height

The height (inches) of heatmap.

Value

A heat map showing ML performance in self-validation and cross-applications.

Examples

df <- data.frame(rbind(t(rmultinom(14, 14*5, c(.21,.6,.12,.38,.099))),
            t(rmultinom(16, 16*5, c(.001,.6,.42,.58,.299))),
            t(rmultinom(30, 30*5, c(.011,.6,.22,.28,.289))),
            t(rmultinom(30, 30*5, c(.091,.6,.32,.18,.209))),
            t(rmultinom(30, 30*5, c(.001,.6,.42,.58,.299)))))
df0 <- data.frame(t(rmultinom(120, 600,c(.001,.6,.2,.3,.299))))
metadata<-data.frame(f_s=factor(rep(c("A", "B"), 60)),
                     f_s1=factor(c(rep(TRUE, 60), rep(FALSE, 60))),
                     f_c=factor(c(rep("C", 30), rep("H", 30), rep("D", 30), rep("P", 30))),
                     age=c(1:60, 2:61)
                     )

table(metadata[, c('f_s', 'f_c')])
clf_res<-rf_clf.by_datasets(df, metadata, nfolds=5, s_category='f_c', c_category='f_s')
clf_cross_appl_res <- rf_clf.cross_appl(clf_res$rf_model_list,
                                        x_list=clf_res$x_list,
                                        y_list=clf_res$y_list)
plot_cross_appl(clf_cross_appl_res, metric="AUROC")

reg_res<-rf_reg.by_datasets(df, metadata, nfolds=5, s_category='f_c', c_category='age')
reg_cross_appl_res <- rf_reg.cross_appl(reg_res,
                                        x_list=reg_res$x_list,
                                        y_list=reg_res$y_list)
plot_cross_appl(reg_cross_appl_res, metric="MAE")

shihuang047/crossRanger documentation built on Feb. 7, 2023, 10:03 p.m.