A named list of package-supplied models can be obtained interactively
with the modelinfo()
function, and includes a descriptive "label" for each,
source "packages" on which the models depend, supported
response variable "types", and "arguments"
that can be specified in calls to the model functions. Function
modelinfo can be called without arguments, with one or more
model functions, variable types, or response variables; and will return
information on all models matching the calling arguments.
## Analysis libraries
library(MachineShop)
library(magrittr)
## All availble models
modelinfo() %>% names
#> [1] "AdaBagModel" "AdaBoostModel" "BARTMachineModel"
#> [4] "BARTModel" "BlackBoostModel" "C50Model"
#> [7] "CForestModel" "CoxModel" "CoxStepAICModel"
#> [10] "EarthModel" "FDAModel" "GAMBoostModel"
#> [13] "GBMModel" "GLMBoostModel" "GLMModel"
#> [16] "GLMStepAICModel" "GLMNetModel" "KNNModel"
#> [19] "LARSModel" "LDAModel" "LMModel"
#> [22] "MDAModel" "NaiveBayesModel" "NNetModel"
#> [25] "ParsnipModel" "PDAModel" "PLSModel"
#> [28] "POLRModel" "QDAModel" "RandomForestModel"
#> [31] "RangerModel" "RFSRCModel" "RPartModel"
#> [34] "SelectedModel" "StackedModel" "SuperModel"
#> [37] "SurvRegModel" "SurvRegStepAICModel" "SVMModel"
#> [40] "SVMANOVAModel" "SVMBesselModel" "SVMLaplaceModel"
#> [43] "SVMLinearModel" "SVMPolyModel" "SVMRadialModel"
#> [46] "SVMSplineModel" "SVMTanhModel" "TreeModel"
#> [49] "TunedModel" "XGBModel" "XGBDARTModel"
#> [52] "XGBLinearModel" "XGBTreeModel"
## Model-specific information
modelinfo(C50Model, CoxModel)
#> $C50Model
#> $C50Model$label
#> [1] "C5.0 Classification"
#>
#> $C50Model$packages
#> [1] "C50"
#>
#> $C50Model$response_types
#> [1] "factor"
#>
#> $C50Model$weights
#> [1] TRUE
#>
#> $C50Model$na.rm
#> [1] "none"
#>
#> $C50Model$arguments
#> function (trials = 1, rules = FALSE, subset = TRUE, bands = 0,
#> winnow = FALSE, noGlobalPruning = FALSE, CF = 0.25, minCases = 2,
#> fuzzyThreshold = FALSE, sample = 0, earlyStopping = TRUE)
#> NULL
#>
#> $C50Model$grid
#> [1] TRUE
#>
#> $C50Model$varimp
#> [1] TRUE
#>
#>
#> $CoxModel
#> $CoxModel$label
#> [1] "Cox Regression"
#>
#> $CoxModel$packages
#> [1] "survival"
#>
#> $CoxModel$response_types
#> [1] "Surv"
#>
#> $CoxModel$weights
#> [1] TRUE
#>
#> $CoxModel$na.rm
#> [1] "all"
#>
#> $CoxModel$arguments
#> function (ties = c("efron", "breslow", "exact"), ...)
#> NULL
#>
#> $CoxModel$grid
#> [1] FALSE
#>
#> $CoxModel$varimp
#> [1] TRUE
## All factor response-specific models
modelinfo(factor(0)) %>% names
#> [1] "AdaBagModel" "AdaBoostModel" "BARTModel"
#> [4] "C50Model" "CForestModel" "EarthModel"
#> [7] "FDAModel" "GBMModel" "GLMModel"
#> [10] "GLMNetModel" "KNNModel" "LDAModel"
#> [13] "LMModel" "MDAModel" "NaiveBayesModel"
#> [16] "NNetModel" "ParsnipModel" "PDAModel"
#> [19] "PLSModel" "QDAModel" "RandomForestModel"
#> [22] "RangerModel" "RFSRCModel" "RPartModel"
#> [25] "SelectedModel" "StackedModel" "SuperModel"
#> [28] "SVMModel" "SVMANOVAModel" "SVMBesselModel"
#> [31] "SVMLaplaceModel" "SVMLinearModel" "SVMPolyModel"
#> [34] "SVMRadialModel" "SVMSplineModel" "SVMTanhModel"
#> [37] "TreeModel" "TunedModel" "XGBModel"
#> [40] "XGBDARTModel" "XGBLinearModel" "XGBTreeModel"
## Identify factor response-specific models
modelinfo(factor(0), AdaBagModel, C50Model, CoxModel) %>% names
#> [1] "AdaBagModel" "C50Model"
## Models for a responses variable
modelinfo(iris$Species) %>% names
#> [1] "AdaBagModel" "AdaBoostModel" "BARTModel"
#> [4] "C50Model" "CForestModel" "EarthModel"
#> [7] "FDAModel" "GBMModel" "GLMModel"
#> [10] "GLMNetModel" "KNNModel" "LDAModel"
#> [13] "LMModel" "MDAModel" "NaiveBayesModel"
#> [16] "NNetModel" "ParsnipModel" "PDAModel"
#> [19] "PLSModel" "QDAModel" "RandomForestModel"
#> [22] "RangerModel" "RFSRCModel" "RPartModel"
#> [25] "SelectedModel" "StackedModel" "SuperModel"
#> [28] "SVMModel" "SVMANOVAModel" "SVMBesselModel"
#> [31] "SVMLaplaceModel" "SVMLinearModel" "SVMPolyModel"
#> [34] "SVMRadialModel" "SVMSplineModel" "SVMTanhModel"
#> [37] "TreeModel" "TunedModel" "XGBModel"
#> [40] "XGBDARTModel" "XGBLinearModel" "XGBTreeModel"
A named list of supplied metrics can be obtained with the metricinfo()
function, and includes a descriptive "label" for each,
whether to "maximize" the metrics for better performance,
their function "arguments", and supported observed and
predicted response variable "types". Function metricinfo()
may be called without arguments, with one or more metric functions, an
observed response variable, an observed and predicted response variable
pair, response variable types, or resampled output; and will return
information on all matching metrics.
## Analysis libraries
library(MachineShop)
library(magrittr)
## All availble metrics
metricinfo() %>% names
#> [1] "accuracy" "auc" "brier" "cindex"
#> [5] "cross_entropy" "f_score" "fnr" "fpr"
#> [9] "gini" "kappa2" "mae" "mse"
#> [13] "msle" "npv" "ppr" "ppv"
#> [17] "pr_auc" "precision" "r2" "recall"
#> [21] "rmse" "rmsle" "roc_auc" "roc_index"
#> [25] "sensitivity" "specificity" "tnr" "tpr"
#> [29] "weighted_kappa2"
## Metric-specific information
metricinfo(auc, r2)
#> $auc
#> $auc$label
#> [1] "Area Under Performance Curve"
#>
#> $auc$maximize
#> [1] TRUE
#>
#> $auc$arguments
#> function (observed, predicted = NULL, weights = NULL, multiclass = c("pairs",
#> "all"), metrics = c(MachineShop::tpr, MachineShop::fpr),
#> stat = MachineShop::settings("stat.Curve"), ...)
#> NULL
#>
#> $auc$response_types
#> observed predicted
#> 1 factor matrix
#> 2 factor numeric
#> 3 PerformanceCurve NULL
#> 4 Resample NULL
#> 5 Surv SurvProbs
#>
#>
#> $r2
#> $r2$label
#> [1] "Coefficient of Determination"
#>
#> $r2$maximize
#> [1] TRUE
#>
#> $r2$arguments
#> function (observed, predicted = NULL, weights = NULL, method = c("mse",
#> "pearson", "spearman"), distr = character(), ...)
#> NULL
#>
#> $r2$response_types
#> observed predicted
#> 1 BinomialVariate numeric
#> 2 matrix matrix
#> 3 numeric numeric
#> 4 Resample NULL
#> 5 Surv numeric
## Metrics for observed and predicted response variable types
metricinfo(factor(0)) %>% names
#> [1] "accuracy" "auc" "brier" "cindex"
#> [5] "cross_entropy" "f_score" "fnr" "fpr"
#> [9] "kappa2" "npv" "ppr" "ppv"
#> [13] "pr_auc" "precision" "recall" "roc_auc"
#> [17] "roc_index" "sensitivity" "specificity" "tnr"
#> [21] "tpr"
metricinfo(factor(0), factor(0)) %>% names
#> [1] "accuracy" "kappa2"
metricinfo(factor(0), matrix(0)) %>% names
#> [1] "accuracy" "auc" "brier" "cross_entropy"
#> [5] "kappa2" "pr_auc" "roc_auc"
## Identify factor-specific metrics
metricinfo(factor(0), accuracy, auc, r2) %>% names
#> [1] "accuracy" "auc"
## Metrics for observed and predicted responses from a model fit
model_fit <- fit(Species ~ ., data = iris, model = C50Model)
obs <- response(model_fit)
pred <- predict(model_fit, type = "prob")
metricinfo(obs, pred) %>% names
#> [1] "accuracy" "auc" "brier" "cross_entropy"
#> [5] "kappa2" "pr_auc" "roc_auc"
## Metrics for resampled output
model_res <- resample(Species ~ ., data = iris, model = C50Model)
metricinfo(model_res) %>% names
#> [1] "accuracy" "auc" "brier" "cross_entropy"
#> [5] "kappa2" "pr_auc" "roc_auc"