Skip to content

Commit

Permalink
refactor: reduce number of hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed Nov 30, 2023
1 parent dc2a983 commit 82e2fbe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/ResultData.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ ResultData = R6Class("ResultData",
} else {
fact = data[, c("uhash", "iteration", "learner_state", "prediction", "task", "learner", "resampling", "param_values", "learner_hash"),
with = FALSE]
set(fact, j = "task_hash", value = hashes(fact$task))
set(fact, j = "learner_phash", value = phashes(fact$learner))
set(fact, j = "resampling_hash", value = hashes(fact$resampling))
setkeyv(fact, c("uhash", "iteration"))

fact[, task_hash := task[[1]]$hash, by = "uhash"]
fact[, learner_phash := learner[[1]]$phash, by = "uhash"]
fact[, resampling_hash := resampling[[1]]$hash, by = "uhash"]

uhashes = data.table(uhash = unique(fact$uhash))
tasks = fact[, list(task = .SD$task[1L]),
Expand All @@ -65,7 +67,6 @@ ResultData = R6Class("ResultData",
set(fact, j = "learner", value = NULL)
set(fact, j = "resampling", value = NULL)
set(fact, j = "param_values", value = NULL)
setkeyv(fact, c("uhash", "iteration"))

if (!store_backends) {
set(tasks, j = "task", value = lapply(tasks$task, task_rm_backend))
Expand Down

0 comments on commit 82e2fbe

Please sign in to comment.