@@ -45,11 +45,11 @@ mlClassificationLogisticMultinomial <- function(jaspResults, dataset, options, .
45
45
# Create the validation measures table
46
46
.mlClassificationTableMetrics(dataset , options , jaspResults , ready , position = 5 )
47
47
48
- # # Create the variable importance table
49
- # .mlTableFeatureImportance(options, jaspResults, ready, position = 6, purpose = "classification")
48
+ # Create the variable importance table
49
+ .mlTableFeatureImportance(options , jaspResults , ready , position = 6 , purpose = " classification" )
50
50
51
- # # Create the shap table
52
- # .mlTableShap(dataset, options, jaspResults, ready, position = 7, purpose = "classification")
51
+ # Create the shap table
52
+ .mlTableShap(dataset , options , jaspResults , ready , position = 7 , purpose = " classification" )
53
53
54
54
.mlClassificationLogisticTableCoef(options , jaspResults , ready , position = 8 )
55
55
@@ -124,12 +124,14 @@ mlClassificationLogisticMultinomial <- function(jaspResults, dataset, options, .
124
124
result [[" test" ]] <- testSet
125
125
result [[" testIndicatorColumn" ]] <- testIndicatorColumn
126
126
result [[" classes" ]] <- dataPredictions
127
- # result[["explainer"]] <- DALEX::explain(result[["model"]], type = "classification", data = result[["train"]], y = result[["train"]][, options[["target"]]], predict_function = function(model, data) predict(model, newdata = data, type = "raw"))
128
- # if (nlevels(result[["testReal"]]) == 2) {
129
- # result[["explainer_fi"]] <- DALEX::explain(result[["model"]], type = "classification", data = result[["train"]], y = as.numeric(result[["train"]][, options[["target"]]]) - 1, predict_function = function(model, data) predict(model, newdata = data, type = "class"))
130
- # } else {
131
- # result[["explainer_fi"]] <- DALEX::explain(result[["model"]], type = "multiclass", data = result[["train"]], y = result[["train"]][, options[["target"]]] , predict_function = function(model, data) predict(model, newdata = data, type = "raw"))
132
- # }
127
+ if (family == " binomial" ) {
128
+ result [[" explainer" ]] <- DALEX :: explain(result [[" model" ]], type = " classification" , data = result [[" train" ]], y = result [[" train" ]][, options [[" target" ]]], predict_function = function (model , data ) data.frame (1 - predict(model , newdata = data , type = " response" ), predict(model , newdata = data , type = " response" )))
129
+ result [[" explainer_fi" ]] <- DALEX :: explain(result [[" model" ]], type = " classification" , data = result [[" train" ]], y = as.numeric(result [[" train" ]][, options [[" target" ]]]) - 1 , predict_function = function (model , data ) round(predict(model , newdata = data , type = " response" ), 0 ) + 1 )
130
+ } else {
131
+ # TODO
132
+ result [[" explainer" ]] <- DALEX :: explain(result [[" model" ]][[" original" ]], type = " multiclass" , data = result [[" train" ]], y = result [[" train" ]][, options [[" target" ]]], predict_function = function (model , data ) VGAM :: predict(model , data , type = " response" ))
133
+ result [[" explainer_fi" ]] <- result [[" explainer" ]]
134
+ }
133
135
return (result )
134
136
}
135
137
0 commit comments