LudvigOlsen/cvms: cvms 1.0.0
Authors/Creators
Description
In
cross_validate()andvalidate(), themodelsargument is renamed toformulas. This is a more meaningful name that was recently introduced incross_validate_fn(). For now, themodelsargument is deprecated, will be used instead offormulasif specified, and will throw a warning.In
cross_validate()andvalidate(), themodel_verboseargument is renamed toverbose. This is a more meaningful name that was recently introduced incross_validate_fn(). For now, themodel_verboseargument is deprecated, will be used instead ofverboseif specified, and will throw a warning.In
cross_validate()andvalidate(), thelinkargument is removed. Consider usingcross_validate_fn()orvalidate_fn()instead, where you have full control over the prediction type fed to the evaluation.In
cross_validate_fn(), thepredict_typeargument is removed. You now have to pass a predict function as that is safer and more transparent.In functions with
family/typeargument, this argument no longer has a default, forcing the user to specify the family/type of the task. This also means that arguments have been reordered. In general, it is safer to name arguments when passing values to them.In
evaluate(),apply_softmaxnow defaults toFALSE. Throws error if probabilities do not add up to 1 row-wise (tolerance of 5 decimals) whentypeismultinomial.
multinomialMCCis now the proper multiclass generalization. Previous versions usedmacro MCC. RemovesMCCfrom the class level results. Removes the option to enableWeighted MCC.multinomialAUCis calculated withpROC::multiclass.roc()instead of in the one-vs-all evaluations. This removesAUC,Lower CI, andUpper CIfrom theClass Level Resultsand removesLower CIandUpper CIfrom the main output tibble. Also removes option to enable "Weighted AUC", "Weighted Lower CI", and "Weighted Upper CI".multinomialAUCis disabled by default, as it can take a long time to calculate for a large set of classes.ROCcolumns now return theROCobjects instead of the extractedsensitivitiesandspecificities, both of which can be extracted from the objects.In
evaluate(), it's no longer possible to pass model objects. It now only evaluates the predictions. This removes the theAIC,AICc,BIC,r2m, andr2cmetrics.In
cross_validateandvalidate(), ther2m, andr2cmetrics are now disabled by default ingaussian. The r-squared metrics are non-predictive and should not be used for model selection. They can be enabled withmetrics = list("r2m" = TRUE, "r2c" = TRUE).In
cross_validate_fn(), theAIC,AICc,BIC,r2m, andr2cmetrics are now disabled by default ingaussian. Only some model types will allow the computation of those metrics, and it is preferable that the user actively makes a choice to include them.In
baseline(), theAIC,AICc,BIC,r2m, andr2cmetrics are now disabled by default ingaussian. It can be unclear whether the IC metrics (computed on thelm()/lmer()model objects) can be compared to those calculated for a given other model function. To avoid such confusion, it is preferable that the user actively makes a choice to include the metrics. The r-squared metrics will only be non-zero when random effects are passed. Given that we shouldn't use the r-squared metrics for model selection, it makes sense to not have them enabled by default.
validate()now returns a tibble with the model objects nested in theModelcolumn. Previously, it returned a list with the results and models. This allows for easier use inmagrittrpipelines (%>%).In multinomial
baseline(), the aggregation approach is changed. The summarized results now properly describe the random evaluations tibble, except for the four new measuresCL_Max,CL_Min,CL_NAs, andCL_INFs, which describe the class level results. Previously,NAswere removed before aggregating the one-vs-all evaluations, meaning that some metric summaries could become inflated if small classes hadNAs. It was also non-transparent that theNAs andINFs were counted in the class level results instead of being a count of random evaluations withNAs orINFs.cv_plot()is removed. It wasn't very useful and has never been developed properly. We aim to provide specialized plotting functions instead.
validate_fn()is added. Validate your custom model function on a test set.confusion_matrix()is added. Create a confusion matrix and calculate associated metrics from your targets and predictions.evaluate_residuals()is added. Calculate common metrics from regression residuals.summarize_metrics()is added. Use it summarize the numeric columns in your dataset with a set of common descriptors. Counts theNAs andInfs. Used bybaseline().select_definitions()is added. Select the columns that define the models, such asDependent,Fixed,Random, and the (unnested) hyperparameters.model_functions()is added. Contains simplemodel_fnexamples that can be used incross_validate_fn()andvalidate_fn()or as starting points.predict_functions()is added. Contains simplepredict_fnexamples that can be used incross_validate_fn()andvalidate_fn()or as starting points.preprocess_functions()is added. Contains simplepreprocess_fnexamples that can be used incross_validate_fn()andvalidate_fn()or as starting points.update_hyperparameters()is added. For managing hyperparameters when writing custom model functions.most_challenging()is added. Finds the data points that were the most difficult to predict.plot_confusion_matrix()is added. Creates aggplotrepresenting a given confusion matrix. Thanks to Malte Lau Petersen (@maltelau), Maris Sala (@marissala) and Kenneth Enevoldsen (@KennethEnevoldsen) for feedback.plot_metric_density()is added. Creates a ggplot density plot for a metric column.font()is added. Utility for setting font settings (size, color, etc.) in plotting functions.simplify_formula()is added. Converts a formula with inline functions to a simple formula where all variables are added together (e.g.y ~ x*z + log(a) + (1|b)->y ~ x + z + a + b). This is useful when passing a formula torecipes::recipe(), which doesn't allow the inline functions.gaussian_metrics(),binomial_metrics(), andmultinomial_metrics()are added. Can be used to select metrics for themetricsargument in manycvmsfunctions.baseline_gaussian(),baseline_binomial(),baseline_multinomial()are added. Simple wrappers forbaseline()that are easier to use and have simpler help files.baseline()has a lot of arguments that are specific to a family, which can be a bit confusing.
winesdataset is added. Contains a list of wine varieties in an approximately Zipfian distribution.musiciansdataset is added. This has been generated for multiclass classification examples.predicted.musiciansdataset is added. This contains cross-validated predictions of themusiciansdataset by three algorithms. Can be used to demonstrate working with predictions from repeated 5-fold stratified cross-validation.
Adds
NRMSE(RNG),NRMSE(IQR),NRMSE(STD),NRMSE(AVG)metrics togaussianevaluations. TheRMSEis normalized by either target range (RNG), target interquartile range (IQR), target standard deviation (STD), or target mean (AVG). OnlyNRMSE(IQR)is enabled by default.Adds
RMSLE,RAE,RSE,RRSE,MALE,MAPE,MSE,TAEandTSEmetrics togaussianevaluations.RMSLE,RAE, andRRSEare enabled by default.Adds Information Criterion metrics (
AIC,AICc,BIC) to thebinomialandmultinomialoutput of some functions (disabled by default). These are based on the fitted model objects and will only work for some types of models.Adds
Positive Classcolumn tobinomialevaluations.
Adds optional
hyperparameterargument tocross_validate_fn(). Pass a list of hyperparameters and every combination of these will be cross-validated.Adds optional
preprocess_fnargument tocross_validate_fn(). This can, for instance, be used to standardize the training and test sets within the function. E.g., by extracting the scaling and centering parameters from the training set and apply them to both the training set and the test fold.Adds
Preprocesscolumn to output whenpreprocess_fnis passed. Contains returned parameters (e.g. mean, sd) used in preprocessing.Adds
preprocess_onceargument tocross_validate_fn(). When preprocessing does not depend on the current formula or hyperparameters, we might as well perform it on each train/test split once, instead of for every model.Adds
metricsargument tobaseline(). Enable the non-default metrics you want a baseline evaluation for.Adds
preprocessingargument tocross_validate()andvalidate(). Currently allows "standardize", "scale", "center", and "range". Results will likely not be affected noticeably by the preprocessing.Adds
add_targetsandadd_predicted_classesarguments tomulticlass_probability_tibble().Adds
Observationcolumn in the nested predictions tibble incross_validate(),cross_validate_fn(),validate(), andvalidate_fn(). These indices can be used to identify which observations are difficult to predict.Adds
SDcolumn in the nested predictions tibble inevaluate()when performing ID aggregated evaluation withid_method = 'mean'. This is the standard deviation of the predictions for the ID.
Adds vignette:
Cross-validating custom model functions with cvmsAdds vignette:
Creating a confusion matrix with cvmsAdds vignette:
The available metrics in cvmsAdds vignette:
Evaluate by ID/group
The
metricsargument now allows setting a boolean for"all"inside the list to enable or disable all the metrics. For instance, the following would disable all the metrics exceptRMSE:metrics = list("all" = FALSE, "RMSE" = TRUE).multinomialevaluation results now contain theResultstibble with the results for each fold column. The main metrics are now averages of these fold column results. Previously, they were not aggregated by fold column first. In the unit tests, this has not altered the results, but it is a more correct approach.The prediction column(s) in
evaluate()must be either numeric or character, depending on the format chosen.In
binomialevaluate(), it's now possible to pass predicted classes instead of probabilities. Probabilities still carry more information though. Both the prediction and target columns must have type character in this format.Changes the required arguments in the
predict_fnfunction passed tocross_validate_fn().Changes the required arguments in the
model_fnfunction passed tocross_validate_fn().Warnings and messages from
preprocess_fnare caught and added toWarnings and Messages. Warnings are counted inOther Warnings.Nesting is now done with
dplyr::group_nestinstead oftidyr::nest_legacyfor speed improvements.caret,mltools, andModelMetricsare no longer dependencies. The confusion matrix metrics have instead been implemented incvms(seeconfusion_matrix()).select_metrics()now works with a wider range of inputs as it no longer depends on aFamilycolumn.The
Fixedcolumn in some of the output tibbles have been moved to make it clearer which model was evaluated.Better handling of inline functions in formulas.
Files
LudvigOlsen/cvms-v1.0.0.zip
Files
(2.0 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:34a532b5e2db80638671c7df4c1172ac
|
2.0 MB | Preview Download |
Additional details
Related works
- Is supplement to
- https://github.com/LudvigOlsen/cvms/tree/v1.0.0 (URL)