ModelOriented / DALEX
Showing 1 of 2 files from the diff.
Other files ignored by Codecov
man/explain.Rd has changed.

@@ -88,9 +88,9 @@
Loading
88 88
#' # keep in mind that for binary classification y parameter has to be numeric  with 0 and 1 values
89 89
#' titanic_ranger_exp <- explain(titanic_ranger, data = titanic_imputed, y = titanic_imputed$survived)
90 90
#'
91 -
#' # multilabel classification
91 +
#' # multiclass task
92 92
#' hr_ranger <- ranger::ranger(status~., data = HR, num.trees = 50, probability = TRUE)
93 -
#' # keep in mind that for multilabel classification y parameter has to be a factor,
93 +
#' # keep in mind that for multiclass y parameter has to be a factor,
94 94
#' # with same levels as in training data
95 95
#' hr_ranger_exp <- explain(hr_ranger, data = HR, y = HR$status)
96 96
#'
@@ -264,8 +264,14 @@
Loading
264 264
  }
265 265
266 266
  if (is.null(model_info)) {
267 -
    # extract defaults
268 -
    task_subtype <- check_if_multiclass(model, predict_function, data[1:2, , drop = FALSE])
267 +
    # let's try to extract defaults
268 +
    # need to rows otherwise the predict function may convert matrix to vector
269 +
    if (!is.null(data) && nrow(data) > 1) {
270 +
      task_subtype <- check_if_multiclass(model, predict_function, data[1:2, , drop = FALSE])
271 +
    } else {
272 +
      # no way to guess
273 +
      task_subtype <- FALSE
274 +
    }
269 275
    model_info <- model_info(model, is_multiclass = task_subtype)
270 276
    verbose_cat("  -> model_info        :  package", model_info$package[1], ", ver.", model_info$ver[1], ", task", model_info$type, "(", color_codes$yellow_start,"default",color_codes$yellow_end, ")", "\n", verbose = verbose)
271 277
  } else {
@@ -385,7 +391,7 @@
Loading
385 391
  }))
386 392
}
387 393
388 -
# check whether model is multilabel classification task
394 +
# check whether model is multiclass task
389 395
check_if_multiclass <- function(model, predict_function, sample_data) {
390 396
  response_sample <- try(predict_function(model, sample_data), silent = TRUE)
391 397
  !is.null(dim(response_sample))
@@ -396,7 +402,7 @@
Loading
396 402
  y - predict_function(model, data)
397 403
}
398 404
399 -
# default residual function for multiclass problems
405 +
# default residual function for multiclass tasks
400 406
residual_function_multiclass <- function(model, data, y, predict_function = yhat) {
401 407
  y_char <- as.character(y)
402 408
  pred <- predict_function(model, data)
Files Coverage
R 86.81%
Project Totals (31 files) 86.81%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
        informational: true
10
    patch:
11
      default:
12
        target: auto
13
        threshold: 1%
14
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading