The as.data.frame function converts an S3 object generated by evalmod to a data frame.

# S3 method for sscurves
as.data.frame(x, row.names = NULL, optional = FALSE, raw_curves = NULL, ...)

# S3 method for mscurves
as.data.frame(x, row.names = NULL, optional = FALSE, raw_curves = NULL, ...)

# S3 method for smcurves
as.data.frame(x, row.names = NULL, optional = FALSE, raw_curves = NULL, ...)

# S3 method for mmcurves
as.data.frame(x, row.names = NULL, optional = FALSE, raw_curves = NULL, ...)

# S3 method for sspoints
as.data.frame(x, row.names = NULL, optional = FALSE, raw_curves = NULL, ...)

# S3 method for mspoints
as.data.frame(x, row.names = NULL, optional = FALSE, raw_curves = NULL, ...)

# S3 method for smpoints
as.data.frame(x, row.names = NULL, optional = FALSE, raw_curves = NULL, ...)

# S3 method for mmpoints
as.data.frame(x, row.names = NULL, optional = FALSE, raw_curves = NULL, ...)

# S3 method for aucroc
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

x

An S3 object generated by evalmod. The as.data.frame function takes one of the following S3 objects.

  1. ROC and Precision-Recall curves (mode = "rocprc")

    S3 object# of models# of test datasets
    sscurvessinglesingle
    mscurvesmultiplesingle
    smcurvessinglemultiple
    mmcurvesmultiplemultiple
  2. Basic evaluation measures (mode = "basic")

    S3 object# of models# of test datasets
    sspointssinglesingle
    mspointsmultiplesingle
    smpointssinglemultiple
    mmpointsmultiplemultiple
  3. Fast AUC (ROC) calculation with the U statistic (mode = "aucroc")

    S3 object# of models# of test datasets
    aucroc--

See the Value section of evalmod for more details.

row.names

Not used by this method.

optional

Not used by this method.

raw_curves

A Boolean value to specify whether raw curves are shown instead of the average curve. It is effective only when raw_curves is set to TRUE of the evalmod function.

...

Not used by this method.

Value

The as.data.frame function returns a data frame.

See also

evalmod for generating S3 objects with performance evaluation measures.

Examples

# \dontrun{ ################################################## ### Single model & single test dataset ### ## Load a dataset with 10 positives and 10 negatives data(P10N10) ## Generate an sscurve object that contains ROC and Precision-Recall curves sscurves <- evalmod(scores = P10N10$scores, labels = P10N10$labels) ## Convert sscurves to a data frame sscurves.df <- as.data.frame(sscurves) ## Show data frame head(sscurves.df)
#> x y modname dsid type #> 1 0.000 0.0 m1 1 ROC #> 2 0.000 0.1 m1 1 ROC #> 3 0.000 0.2 m1 1 ROC #> 4 0.001 0.2 m1 1 ROC #> 5 0.002 0.2 m1 1 ROC #> 6 0.003 0.2 m1 1 ROC
## Generate an sspoints object that contains basic evaluation measures sspoints <- evalmod(mode = "basic", scores = P10N10$scores, labels = P10N10$labels) ## Convert sspoints to a data frame sspoints.df <- as.data.frame(sspoints) ## Show data frame head(sspoints.df)
#> x y modname dsid type #> 1 0.00 NA m1 1 score #> 2 0.05 20 m1 1 score #> 3 0.10 19 m1 1 score #> 4 0.15 18 m1 1 score #> 5 0.20 17 m1 1 score #> 6 0.25 16 m1 1 score
################################################## ### Multiple models & single test dataset ### ## Create sample datasets with 100 positives and 100 negatives samps <- create_sim_samples(1, 100, 100, "all") mdat <- mmdata(samps[["scores"]], samps[["labels"]], modnames = samps[["modnames"]]) ## Generate an mscurve object that contains ROC and Precision-Recall curves mscurves <- evalmod(mdat) ## Convert mscurves to a data frame mscurves.df <- as.data.frame(mscurves) ## Show data frame head(mscurves.df)
#> x y modname dsid type #> 1 0.000 0.00 random 1 ROC #> 2 0.000 0.01 random 1 ROC #> 3 0.000 0.02 random 1 ROC #> 4 0.001 0.02 random 1 ROC #> 5 0.002 0.02 random 1 ROC #> 6 0.003 0.02 random 1 ROC
## Generate an mspoints object that contains basic evaluation measures mspoints <- evalmod(mdat, mode = "basic") ## Convert mspoints to a data frame mspoints.df <- as.data.frame(mspoints) ## Show data frame head(mspoints.df)
#> x y modname dsid type #> 1 0.000 NA random 1 score #> 2 0.005 2.755418 random 1 score #> 3 0.010 2.682557 random 1 score #> 4 0.015 2.564408 random 1 score #> 5 0.020 2.211769 random 1 score #> 6 0.025 2.126850 random 1 score
################################################## ### Single model & multiple test datasets ### ## Create sample datasets with 100 positives and 100 negatives samps <- create_sim_samples(10, 100, 100, "good_er") mdat <- mmdata(samps[["scores"]], samps[["labels"]], modnames = samps[["modnames"]], dsids = samps[["dsids"]]) ## Generate an smcurve object that contains ROC and Precision-Recall curves smcurves <- evalmod(mdat, raw_curves = TRUE) ## Convert smcurves to a data frame smcurves.df <- as.data.frame(smcurves) ## Show data frame head(smcurves.df)
#> x y modname dsid type #> 1 0 0.00 good_er 1 ROC #> 2 0 0.01 good_er 1 ROC #> 3 0 0.02 good_er 1 ROC #> 4 0 0.03 good_er 1 ROC #> 5 0 0.04 good_er 1 ROC #> 6 0 0.05 good_er 1 ROC
## Generate an smpoints object that contains basic evaluation measures smpoints <- evalmod(mdat, mode = "basic") ## Convert smpoints to a data frame smpoints.df <- as.data.frame(smpoints) ## Show data frame head(smpoints.df)
#> x y ymin ymax modname type #> 1 0.000 NA NA NA good_er score #> 2 0.005 0.9817259 0.9729559 0.9904959 good_er score #> 3 0.010 0.9724147 0.9626556 0.9821739 good_er score #> 4 0.015 0.9622373 0.9497315 0.9747430 good_er score #> 5 0.020 0.9462811 0.9362615 0.9563008 good_er score #> 6 0.025 0.9377157 0.9256513 0.9497802 good_er score
################################################## ### Multiple models & multiple test datasets ### ## Create sample datasets with 100 positives and 100 negatives samps <- create_sim_samples(10, 100, 100, "all") mdat <- mmdata(samps[["scores"]], samps[["labels"]], modnames = samps[["modnames"]], dsids = samps[["dsids"]]) ## Generate an mscurve object that contains ROC and Precision-Recall curves mmcurves <- evalmod(mdat, raw_curves = TRUE) ## Convert mmcurves to a data frame mmcurves.df <- as.data.frame(mmcurves) ## Show data frame head(mmcurves.df)
#> x y modname dsid type #> 1 0.000 0 random 1 ROC #> 2 0.001 0 random 1 ROC #> 3 0.002 0 random 1 ROC #> 4 0.003 0 random 1 ROC #> 5 0.004 0 random 1 ROC #> 6 0.005 0 random 1 ROC
## Generate an mmpoints object that contains basic evaluation measures mmpoints <- evalmod(mdat, mode = "basic") ## Convert mmpoints to a data frame mmpoints.df <- as.data.frame(mmpoints) ## Show data frame head(mmpoints.df)
#> x y ymin ymax modname type #> 1 0.000 NA NA NA random score #> 2 0.005 2.739291 2.508815 2.969767 random score #> 3 0.010 2.345126 2.261530 2.428722 random score #> 4 0.015 2.180498 2.060028 2.300968 random score #> 5 0.020 2.038010 1.933964 2.142056 random score #> 6 0.025 1.962737 1.864846 2.060628 random score
################################################## ### N-fold cross validation datasets ### ## Load test data data(M2N50F5) ## Speficy nessesary columns to create mdat cvdat <- mmdata(nfold_df = M2N50F5, score_cols = c(1, 2), lab_col = 3, fold_col = 4, modnames = c("m1", "m2"), dsids = 1:5) ## Generate an mmcurve object that contains ROC and Precision-Recall curves cvcurves <- evalmod(cvdat) ## Convert mmcurves to a data frame cvcurves.df <- as.data.frame(cvcurves) ## Show data frame head(cvcurves.df)
#> x y ymin ymax modname type #> 1 0.000 0.00 0.00000000 0.0000000 m1 ROC #> 2 0.000 0.34 -0.02980526 0.7098053 m1 ROC #> 3 0.001 0.34 -0.02980526 0.7098053 m1 ROC #> 4 0.002 0.34 -0.02980526 0.7098053 m1 ROC #> 5 0.003 0.34 -0.02980526 0.7098053 m1 ROC #> 6 0.004 0.34 -0.02980526 0.7098053 m1 ROC
## Generate an mmpoints object that contains basic evaluation measures cvpoints <- evalmod(cvdat, mode = "basic") ## Convert mmpoints to a data frame cvpoints.df <- as.data.frame(cvpoints) ## Show data frame head(cvpoints.df)
#> x y ymin ymax modname type #> 1 0.0 NA NA NA m1 score #> 2 0.1 1.88207537 1.6457350 2.118416 m1 score #> 3 0.2 1.20510611 0.8322451 1.577967 m1 score #> 4 0.3 0.77534711 0.2820198 1.268674 m1 score #> 5 0.4 0.44011784 0.1146357 0.765600 m1 score #> 6 0.5 -0.02838804 -0.3363391 0.279563 m1 score
################################################## ### AUC with the U statistic ### ## mode = "aucroc" data(P10N10) uauc1 <- evalmod(scores = P10N10$scores, labels = P10N10$labels, mode="aucroc") # as.data.frame 'aucroc' as.data.frame(uauc1)
#> modnames dsids aucs ustats #> 1 m1 1 0.72 72
## mode = "aucroc" samps <- create_sim_samples(10, 100, 100, "all") mdat <- mmdata(samps[["scores"]], samps[["labels"]], modnames = samps[["modnames"]], dsids = samps[["dsids"]]) uauc2 <- evalmod(mdat, mode="aucroc") # as.data.frame 'aucroc' head(as.data.frame(uauc2))
#> modnames dsids aucs ustats #> 1 random 1 0.5507 5507 #> 2 poor_er 1 0.8031 8031 #> 3 good_er 1 0.7532 7532 #> 4 excel 1 0.9899 9899 #> 5 perf 1 1.0000 10000 #> 6 random 2 0.5106 5106
# }