diff --git a/R/commonMachineLearningRegression.R b/R/commonMachineLearningRegression.R index 764ec77a..4578963d 100644 --- a/R/commonMachineLearningRegression.R +++ b/R/commonMachineLearningRegression.R @@ -750,6 +750,67 @@ } } +.mlPredictionsToMatrix <- function(predictions) { + if (is.data.frame(predictions) || is.matrix(predictions)) { + return(as.matrix(predictions)) + } + if (is.array(predictions)) { + if (length(dim(predictions)) == 3) { + return(predictions[, , dim(predictions)[3], drop = FALSE]) + } + return(as.matrix(predictions)) + } + if (is.atomic(predictions)) { + return(matrix(predictions, ncol = 1)) + } + return(NULL) +} + +.mlSinglePredictorShapFallback <- function(observation, explainer, purpose, predictedLabel = NULL, classLevels = NULL) { + trainPredictions <- explainer$predict_function(explainer$model, explainer$data) + casePrediction <- explainer$predict_function(explainer$model, observation) + + if (purpose == "regression") { + casePrediction <- as.numeric(casePrediction)[1] + basePrediction <- mean(as.numeric(trainPredictions), na.rm = TRUE) + return(list( + predicted = casePrediction, + base = basePrediction, + contribution = casePrediction - basePrediction + )) + } + + trainPredictions <- .mlPredictionsToMatrix(trainPredictions) + casePrediction <- .mlPredictionsToMatrix(casePrediction) + + if (is.null(trainPredictions) || is.null(casePrediction) || ncol(casePrediction) < 1) { + stop("Could not compute fallback additive explanations for classification.") + } + + predictedIndex <- which.max(casePrediction[1, ]) + predictedProb <- casePrediction[1, predictedIndex] + baseProb <- mean(trainPredictions[, predictedIndex], na.rm = TRUE) + + if (!is.null(predictedLabel)) { + label <- predictedLabel + } else { + labels <- classLevels + if (is.null(labels) || length(labels) < predictedIndex) { + labels <- colnames(casePrediction) + } + if (is.null(labels) || length(labels) < predictedIndex) { + labels <- as.character(seq_len(ncol(casePrediction))) + } + label <- labels[predictedIndex] + } + + return(list( + predicted = paste0(label, " (", round(predictedProb, 3), ")"), + base = baseProb, + contribution = predictedProb - baseProb + )) +} + .mlTableShap <- function(dataset, options, jaspResults, ready, position, purpose, model = NULL) { if (!is.null(jaspResults[["tableShap"]]) || !options[["tableShap"]]) { return() @@ -807,7 +868,32 @@ p <- try({ for (i in seq_along(from:to)) { out[i, 1] <- (from:to)[i] - shap <- DALEX::predict_parts(explainer, new_observation = as.data.frame(x_test[(from:to)[i], predictors, drop = FALSE])) + observation <- as.data.frame(x_test[(from:to)[i], predictors, drop = FALSE]) + shap <- try(DALEX::predict_parts(explainer, new_observation = observation), silent = TRUE) + + if (isTryError(shap)) { + fallbackRequired <- length(predictors) == 1 && + is.numeric(x_test[[predictors[1]]]) && + grepl("replacement has 1 row, data has", .extractErrorMessage(shap), fixed = TRUE) + + if (!fallbackRequired) { + stop(shap) + } + + fallback <- .mlSinglePredictorShapFallback( + observation = observation, + explainer = explainer, + purpose = purpose, + predictedLabel = if (purpose == "classification" && !is.null(model)) as.character(predictions[i]) else NULL, + classLevels = if (purpose == "classification" && is.null(model)) levels(result[["test"]][, options[["target"]]]) else NULL + ) + + out[i, 2] <- fallback[["predicted"]] + out[i, 3] <- fallback[["base"]] + out[i, 4] <- fallback[["contribution"]] + next + } + if (purpose == "regression") { out[i, 2] <- shap[which(shap[["variable"]] == "prediction"), "contribution"] } else { diff --git a/tests/testthat/_snaps/mlclassificationboosting/data-split.new.svg b/tests/testthat/_snaps/mlclassificationboosting/data-split.new.svg new file mode 100644 index 00000000..689c5b50 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationboosting/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 114 +Validation: 29 +Test: 35 +Total: 178 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlclassificationboosting/relative-influence-plot.new.svg b/tests/testthat/_snaps/mlclassificationboosting/relative-influence-plot.new.svg new file mode 100644 index 00000000..1293ceb8 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationboosting/relative-influence-plot.new.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Proanthocyanins +Alcalinity +Nonflavanoids +Ash +Magnesium +Malic +Phenols +Dilution +Hue +Alcohol +Flavanoids +Color +Proline + + + + + + + + + +0 +5 +10 +15 +20 +25 +30 +35 +Relative Influence +relative-influence-plot + + diff --git a/tests/testthat/_snaps/mlclassificationdecisiontree/data-split.new.svg b/tests/testthat/_snaps/mlclassificationdecisiontree/data-split.new.svg new file mode 100644 index 00000000..b254084a --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationdecisiontree/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 96 +Validation: 24 +Test: 30 +Total: 150 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlclassificationdecisiontree/decision-tree-plot.new.svg b/tests/testthat/_snaps/mlclassificationdecisiontree/decision-tree-plot.new.svg new file mode 100644 index 00000000..43ac1390 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationdecisiontree/decision-tree-plot.new.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +< + -0.741 + + + -0.741 + +< + 0.591 + + + 0.591 + +Petal.Length +n = 96 + +setosa +n = 30 + +Petal.Width +n = 66 + +versicolor +n = 32 + +virginica +n = 34 + +setosa +n = 30 + +versicolor +n = 32 + +virginica +n = 34 + + + + + +decision-tree-plot + + diff --git a/tests/testthat/_snaps/mlclassificationknn/data-split.new.svg b/tests/testthat/_snaps/mlclassificationknn/data-split.new.svg new file mode 100644 index 00000000..689c5b50 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationknn/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 114 +Validation: 29 +Test: 35 +Total: 178 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlclassificationlda/data-split.new.svg b/tests/testthat/_snaps/mlclassificationlda/data-split.new.svg new file mode 100644 index 00000000..c71e60c8 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlda/data-split.new.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + +Train: 143 +Test: 35 +Total: 178 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-1.new.svg b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-1.new.svg new file mode 100644 index 00000000..8671359b --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-1.new.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + +LD1 + + +linear-discriminant-matrix-subplot-1 + + diff --git a/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-2.new.svg b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-2.new.svg new file mode 100644 index 00000000..0e26527a --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-2.new.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + +LD2 + + +linear-discriminant-matrix-subplot-2 + + diff --git a/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-3.new.svg b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-3.new.svg new file mode 100644 index 00000000..2f335974 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-3.new.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + +LD1 + + +linear-discriminant-matrix-subplot-3 + + diff --git a/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-4.new.svg b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-4.new.svg new file mode 100644 index 00000000..5ef6e498 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-4.new.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-6 +-4 +-2 +0 +2 +4 +6 +8 +Density +linear-discriminant-matrix-subplot-4 + + diff --git a/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-5.new.svg b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-5.new.svg new file mode 100644 index 00000000..4cbffa76 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-5.new.svg @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Type + + + + + + +1 +2 +3 +linear-discriminant-matrix-subplot-5 + + diff --git a/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-6.new.svg b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-6.new.svg new file mode 100644 index 00000000..eb5317c1 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-6.new.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + +LD2 + + +linear-discriminant-matrix-subplot-6 + + diff --git a/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-8.new.svg b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-8.new.svg new file mode 100644 index 00000000..fb2ecf61 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlda/linear-discriminant-matrix-subplot-8.new.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-8 +-6 +-4 +-2 +0 +2 +4 +6 +Density +linear-discriminant-matrix-subplot-8 + + diff --git a/tests/testthat/_snaps/mlclassificationlogisticmultinomial/data-split-1.new.svg b/tests/testthat/_snaps/mlclassificationlogisticmultinomial/data-split-1.new.svg new file mode 100644 index 00000000..3af22552 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlogisticmultinomial/data-split-1.new.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + +Train: 160 +Test: 40 +Total: 200 + + + + + +data-split-1 + + diff --git a/tests/testthat/_snaps/mlclassificationlogisticmultinomial/data-split-2.new.svg b/tests/testthat/_snaps/mlclassificationlogisticmultinomial/data-split-2.new.svg new file mode 100644 index 00000000..a1148ca2 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationlogisticmultinomial/data-split-2.new.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + +Train: 120 +Test: 30 +Total: 150 + + + + + +data-split-2 + + diff --git a/tests/testthat/_snaps/mlclassificationnaivebayes/data-split.new.svg b/tests/testthat/_snaps/mlclassificationnaivebayes/data-split.new.svg new file mode 100644 index 00000000..fa95a138 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationnaivebayes/data-split.new.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + +Train: 120 +Test: 30 +Total: 150 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlclassificationrandomforest/data-split.new.svg b/tests/testthat/_snaps/mlclassificationrandomforest/data-split.new.svg new file mode 100644 index 00000000..689c5b50 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationrandomforest/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 114 +Validation: 29 +Test: 35 +Total: 178 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlclassificationrandomforest/mean-decrease-in-accuracy.new.svg b/tests/testthat/_snaps/mlclassificationrandomforest/mean-decrease-in-accuracy.new.svg new file mode 100644 index 00000000..5a280d98 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationrandomforest/mean-decrease-in-accuracy.new.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Magnesium +Ash +Alcalinity +Proanthocyanins +Malic +Nonflavanoids +Hue +Alcohol +Phenols +Color +Dilution +Flavanoids +Proline + + + + + + + +0.00 +0.05 +0.10 +0.15 +0.20 +0.25 +Mean Decrease in Accuracy +mean-decrease-in-accuracy + + diff --git a/tests/testthat/_snaps/mlclassificationrandomforest/total-increase-in-node-purity.new.svg b/tests/testthat/_snaps/mlclassificationrandomforest/total-increase-in-node-purity.new.svg new file mode 100644 index 00000000..e2c5db28 --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationrandomforest/total-increase-in-node-purity.new.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Nonflavanoids +Proanthocyanins +Phenols +Magnesium +Malic +Ash +Alcalinity +Flavanoids +Hue +Dilution +Proline +Alcohol +Color + + + + + + + + + +-0.02 +0.00 +0.02 +0.04 +0.06 +0.08 +0.10 +0.12 +Total Increase in Node Purity +total-increase-in-node-purity + + diff --git a/tests/testthat/_snaps/mlclassificationsvm/data-split.new.svg b/tests/testthat/_snaps/mlclassificationsvm/data-split.new.svg new file mode 100644 index 00000000..b254084a --- /dev/null +++ b/tests/testthat/_snaps/mlclassificationsvm/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 96 +Validation: 24 +Test: 30 +Total: 150 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlclusteringdensitybased/all-predictors.new.svg b/tests/testthat/_snaps/mlclusteringdensitybased/all-predictors.new.svg new file mode 100644 index 00000000..780d3aad --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringdensitybased/all-predictors.new.svg @@ -0,0 +1,340 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 + + + + + + +Alcohol +Malic +Ash +Alcalinity +Magnesium +Phenols +Flavanoids +Nonflavanoids +Proanthocyanins +Color +Hue +Dilution +Proline +Cluster Mean + + +Cluster + + + + + + + + + + +1 +2 +3 +4 +Noisepoint +all-predictors + + diff --git a/tests/testthat/_snaps/mlclusteringdensitybased/k-distance-plot.new.svg b/tests/testthat/_snaps/mlclusteringdensitybased/k-distance-plot.new.svg new file mode 100644 index 00000000..4f63f741 --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringdensitybased/k-distance-plot.new.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + +Maximum curvature = 2.16 + + + + + + + + +0 +1 +2 +3 +4 +5 +6 + + + + + + + + + + + + + +0 +50 +100 +150 +200 +Points Sorted by Distance +5-Nearest Neighbors +Distance +k-distance-plot + + diff --git a/tests/testthat/_snaps/mlclusteringfuzzycmeans/all-predictors.new.svg b/tests/testthat/_snaps/mlclusteringfuzzycmeans/all-predictors.new.svg new file mode 100644 index 00000000..b5db25f8 --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringfuzzycmeans/all-predictors.new.svg @@ -0,0 +1,287 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +Alcohol +Malic +Ash +Alcalinity +Magnesium +Phenols +Flavanoids +Nonflavanoids +Proanthocyanins +Color +Hue +Dilution +Proline +Cluster Mean + + +Cluster + + + + + + + + +1 +2 +3 +4 +all-predictors + + diff --git a/tests/testthat/_snaps/mlclusteringhierarchical/all-predictors.new.svg b/tests/testthat/_snaps/mlclusteringhierarchical/all-predictors.new.svg new file mode 100644 index 00000000..655679df --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringhierarchical/all-predictors.new.svg @@ -0,0 +1,456 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 +3 +4 + + + + + + + + + +Alcohol +Malic +Ash +Alcalinity +Magnesium +Phenols +Flavanoids +Nonflavanoids +Proanthocyanins +Color +Hue +Dilution +Proline +Cluster Mean + + +Cluster + + + + + + + + + + + + + + +1 +2 +4 +5 +6 +7 +8 +all-predictors + + diff --git a/tests/testthat/_snaps/mlclusteringhierarchical/dendogram.new.svg b/tests/testthat/_snaps/mlclusteringhierarchical/dendogram.new.svg new file mode 100644 index 00000000..04115d17 --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringhierarchical/dendogram.new.svg @@ -0,0 +1,745 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +x +dendogram + + diff --git a/tests/testthat/_snaps/mlclusteringkmeans/all-predictors-2.new.svg b/tests/testthat/_snaps/mlclusteringkmeans/all-predictors-2.new.svg new file mode 100644 index 00000000..d9271b15 --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringkmeans/all-predictors-2.new.svg @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 + + + + + + +Alcohol +Malic +Ash +Alcalinity +Magnesium +Phenols +Flavanoids +Nonflavanoids +Proanthocyanins +Color +Hue +Dilution +Proline +Cluster Mean + + +Cluster + + + + + + + + + + + + +1 +2 +3 +4 +5 +6 +all-predictors-2 + + diff --git a/tests/testthat/_snaps/mlclusteringkmeans/all-predictors-3.new.svg b/tests/testthat/_snaps/mlclusteringkmeans/all-predictors-3.new.svg new file mode 100644 index 00000000..0e7ec666 --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringkmeans/all-predictors-3.new.svg @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2.0 +-1.5 +-1.0 +-0.5 +0.0 +0.5 +1.0 +1.5 + + + + + + + + + +Alcohol +Malic +Ash +Alcalinity +Magnesium +Phenols +Flavanoids +Nonflavanoids +Proanthocyanins +Color +Hue +Dilution +Proline +Cluster Mean + + +Cluster + + + + + + + + + + +1 +2 +3 +4 +5 +all-predictors-3 + + diff --git a/tests/testthat/_snaps/mlclusteringkmeans/all-predictors.new.svg b/tests/testthat/_snaps/mlclusteringkmeans/all-predictors.new.svg new file mode 100644 index 00000000..1be56706 --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringkmeans/all-predictors.new.svg @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 +4 + + + + + + + + +Alcohol +Malic +Ash +Alcalinity +Magnesium +Phenols +Flavanoids +Nonflavanoids +Proanthocyanins +Color +Hue +Dilution +Proline +Cluster Mean + + +Cluster + + + + + + + + + + +1 +2 +3 +4 +5 +all-predictors + + diff --git a/tests/testthat/_snaps/mlclusteringmodelbased/all-predictors.new.svg b/tests/testthat/_snaps/mlclusteringmodelbased/all-predictors.new.svg new file mode 100644 index 00000000..efb20b5d --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringmodelbased/all-predictors.new.svg @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-1.5 +-1.0 +-0.5 +0.0 +0.5 +1.0 +1.5 + + + + + + + + +Alcohol +Malic +Ash +Alcalinity +Magnesium +Phenols +Flavanoids +Nonflavanoids +Proanthocyanins +Color +Hue +Dilution +Proline +Cluster Mean + + +Cluster + + + + + + +1 +2 +3 +all-predictors + + diff --git a/tests/testthat/_snaps/mlclusteringrandomforest/all-predictors.new.svg b/tests/testthat/_snaps/mlclusteringrandomforest/all-predictors.new.svg new file mode 100644 index 00000000..b86a5421 --- /dev/null +++ b/tests/testthat/_snaps/mlclusteringrandomforest/all-predictors.new.svg @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-1.5 +-1.0 +-0.5 +0.0 +0.5 +1.0 +1.5 + + + + + + + + +Alcohol +Malic +Ash +Alcalinity +Magnesium +Phenols +Flavanoids +Nonflavanoids +Proanthocyanins +Color +Hue +Dilution +Proline +Cluster Mean + + +Cluster + + + + + + +1 +2 +3 +all-predictors + + diff --git a/tests/testthat/_snaps/mlregressionboosting/data-split.new.svg b/tests/testthat/_snaps/mlregressionboosting/data-split.new.svg new file mode 100644 index 00000000..689c5b50 --- /dev/null +++ b/tests/testthat/_snaps/mlregressionboosting/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 114 +Validation: 29 +Test: 35 +Total: 178 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlregressionboosting/relative-influence-plot.new.svg b/tests/testthat/_snaps/mlregressionboosting/relative-influence-plot.new.svg new file mode 100644 index 00000000..53e8d6e5 --- /dev/null +++ b/tests/testthat/_snaps/mlregressionboosting/relative-influence-plot.new.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Ash +Dilution +Magnesium +Nonflavanoids +Alcalinity +Malic +Proanthocyanins +Hue +Flavanoids +Phenols +Proline +Color + + + + + + + + + +0 +10 +20 +30 +40 +50 +60 +70 +Relative Influence +relative-influence-plot + + diff --git a/tests/testthat/_snaps/mlregressiondecisiontree/data-split.new.svg b/tests/testthat/_snaps/mlregressiondecisiontree/data-split.new.svg new file mode 100644 index 00000000..b254084a --- /dev/null +++ b/tests/testthat/_snaps/mlregressiondecisiontree/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 96 +Validation: 24 +Test: 30 +Total: 150 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlregressiondecisiontree/decision-tree-plot.new.svg b/tests/testthat/_snaps/mlregressiondecisiontree/decision-tree-plot.new.svg new file mode 100644 index 00000000..ca57122f --- /dev/null +++ b/tests/testthat/_snaps/mlregressiondecisiontree/decision-tree-plot.new.svg @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +< + 0.449 + +< + -0.203 + +< + 0.442 + + + 0.442 + + + -0.203 + +< + -0.705 + + + -0.705 + + + 0.449 + +< + 1.3 + +< + 1.12 + + + 0.46 + +< + 0.46 + + + 1.12 + + + 1.3 + +Petal.Length +n = 96 + +Petal.Length +n = 54 + +Sepal.Width +n = 33 + +4.73 +n = 17 + +5.19 +n = 16 + +Sepal.Width +n = 21 + +5.57 +n = 12 + +5.92 +n = 9 + +Petal.Length +n = 42 + +Petal.Width +n = 34 + +Petal.Width +n = 23 + +6.19 +n = 16 + +6.66 +n = 7 + +6.60 +n = 11 + +7.58 +n = 8 + +4.73 +n = 17 + +5.19 +n = 16 + +5.57 +n = 12 + +5.92 +n = 9 + +6.19 +n = 16 + +6.66 +n = 7 + +6.60 +n = 11 + +7.58 +n = 8 + + + + + +decision-tree-plot + + diff --git a/tests/testthat/_snaps/mlregressionknn/data-split.new.svg b/tests/testthat/_snaps/mlregressionknn/data-split.new.svg new file mode 100644 index 00000000..689c5b50 --- /dev/null +++ b/tests/testthat/_snaps/mlregressionknn/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 114 +Validation: 29 +Test: 35 +Total: 178 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlregressionlinear/data-split.new.svg b/tests/testthat/_snaps/mlregressionlinear/data-split.new.svg new file mode 100644 index 00000000..fa95a138 --- /dev/null +++ b/tests/testthat/_snaps/mlregressionlinear/data-split.new.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + +Train: 120 +Test: 30 +Total: 150 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlregressionrandomforest/data-split.new.svg b/tests/testthat/_snaps/mlregressionrandomforest/data-split.new.svg new file mode 100644 index 00000000..689c5b50 --- /dev/null +++ b/tests/testthat/_snaps/mlregressionrandomforest/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 114 +Validation: 29 +Test: 35 +Total: 178 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlregressionrandomforest/mean-decrease-in-accuracy.new.svg b/tests/testthat/_snaps/mlregressionrandomforest/mean-decrease-in-accuracy.new.svg new file mode 100644 index 00000000..997ef645 --- /dev/null +++ b/tests/testthat/_snaps/mlregressionrandomforest/mean-decrease-in-accuracy.new.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Nonflavanoids +Magnesium +Proanthocyanins +Dilution +Ash +Alcalinity +Hue +Phenols +Malic +Flavanoids +Proline +Color + + + + + + + + + + +-0.05 +0.00 +0.05 +0.10 +0.15 +0.20 +0.25 +0.30 +0.35 +Mean Decrease in Accuracy +mean-decrease-in-accuracy + + diff --git a/tests/testthat/_snaps/mlregressionrandomforest/total-increase-in-node-purity.new.svg b/tests/testthat/_snaps/mlregressionrandomforest/total-increase-in-node-purity.new.svg new file mode 100644 index 00000000..f981e064 --- /dev/null +++ b/tests/testthat/_snaps/mlregressionrandomforest/total-increase-in-node-purity.new.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Nonflavanoids +Proanthocyanins +Magnesium +Ash +Dilution +Hue +Malic +Alcalinity +Proline +Phenols +Flavanoids +Color + + + + + + +0 +2 +4 +6 +8 +Total Increase in Node Purity +total-increase-in-node-purity + + diff --git a/tests/testthat/_snaps/mlregressionregularized/data-split.new.svg b/tests/testthat/_snaps/mlregressionregularized/data-split.new.svg new file mode 100644 index 00000000..689c5b50 --- /dev/null +++ b/tests/testthat/_snaps/mlregressionregularized/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 114 +Validation: 29 +Test: 35 +Total: 178 + + + + + +data-split + + diff --git a/tests/testthat/_snaps/mlregressionsvm/data-split.new.svg b/tests/testthat/_snaps/mlregressionsvm/data-split.new.svg new file mode 100644 index 00000000..b254084a --- /dev/null +++ b/tests/testthat/_snaps/mlregressionsvm/data-split.new.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Train: 96 +Validation: 24 +Test: 30 +Total: 150 + + + + + +data-split + +