Skip to content

Commit

Permalink
fix Task printer for tasks without backend
Browse files Browse the repository at this point in the history
  • Loading branch information
lona-k committed Nov 11, 2024
1 parent ec43622 commit a2d762b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions R/Task.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,21 @@ Task = R6Class("Task",
cli_li(sprintf("Target: %s", self$target_names))

if (class(self)[1L] == "TaskClassif") {
class_freqs = table(self$truth()) / self$nrow * 100 # class frequency percentages
class_freqs = class_freqs[order(-class_freqs, names(class_freqs))] # order: class frequency, then names
classes = if("twoclass" %in% self$properties) {
sprintf("%s (positive class, %.0f%%), %s (%.0f%%)",
self$positive, class_freqs[[self$positive]], self$negative, class_freqs[[self$negative]])
if (!is.null(self$backend)) {
class_freqs = table(self$truth()) / self$nrow * 100
class_freqs = class_freqs[order(-class_freqs, names(class_freqs))] # Order by class frequency, then names
classes = if ("twoclass" %in% self$properties) {
sprintf("%s (positive class, %.0f%%), %s (%.0f%%)",
self$positive, class_freqs[[self$positive]], self$negative, class_freqs[[self$negative]])
} else {
paste(sprintf("%s (%.0f%%)", names(class_freqs), class_freqs), collapse = ", ")
}
} else {
class_str = paste(sprintf("%s (%.0f%%)", names(class_freqs), class_freqs), collapse = ", ")
classes = paste(self$class_names, collapse = ", ")
}
cli_li(sprintf("Target classes: %s", classes))
}


cli_li(sprintf("Properties: %s", self$properties))

types = self$feature_types
if (nrow(types)) {
id = type = NULL
Expand Down

0 comments on commit a2d762b

Please sign in to comment.