context("Test Tracker")
test_database <- "unittest_mllogr"
test_collection <- "test_generic_tracker"
test_tracker <- Tracker$new(
database = test_database,
collection = test_collection,
control = list(id_columns = c("a", "b"))
)
test_that("md5 works.", {
expect_equal(
md5(data.frame(a = c(1, 2, 1), b = c(5, 4, 3))),
"063643d0f4958e0af2f1a17acb1038fb"
)
expect_equal(
md5(data.frame(a = c(2, 1, 1), b = c(4, 3, 5))),
"063643d0f4958e0af2f1a17acb1038fb"
)
expect_false(
md5(data.frame(a = c(2, 1, 1), b = c(5, 4, 3))) ==
"063643d0f4958e0af2f1a17acb1038fb"
)
})
test_tracker$set(
experiment_name = "experiment_name",
experiment_description = "experiment_description",
model = list(a = 1, "2", 3),
model_name = "model_name",
model_parameters = "model_parameters",
model_features = "model_features",
model_target = "model_target",
model_performance = "model_performance",
resampling_strategy = "resampling_strategy",
preprocessing_strategy = "preprocessing_strategy",
train_val_test_shares = "train_val_test_shares",
test_frame = data.frame(a = c(1, 2, 1), b = c(5, 4, 3))
)
test_that("log works.", {
dbconnection <- mongolite::mongo(
db = test_tracker$database,
collection = test_tracker$collection
)
dbconnection$remove("{}")
test_tracker$log()
test_log <- dbconnection$find("{}")
expect_true("timestamp" %in% names(test_log))
expect_true("uuid" %in% names(test_log))
expect_equal(
test_log[, names(test_log) != c("timestamp", "uuid")],
structure(list(
experiment_name = list("experiment_name"),
experiment_description = list("experiment_description"),
model = structure(list(
a = list(1),
`2` = list("2"),
`3` = list(3)
), class = "data.frame", row.names = 1L),
model_name = list("model_name"),
model_parameters = list("model_parameters"),
model_features = list("model_features"),
model_target = list("model_target"),
model_performance = list("model_performance"),
resampling_strategy = list("resampling_strategy"),
preprocessing_strategy = list("preprocessing_strategy"),
train_val_test_shares = list("train_val_test_shares"),
test_frame = list("063643d0f4958e0af2f1a17acb1038fb")
), class = "data.frame", row.names = 1L)
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.