Nothing
# First test if all selectable learners are also available
familiar:::test_all_learners_available(
learners = familiar:::.get_available_survival_regression_learners(show_general = TRUE))
# Don't perform any further tests on CRAN due to time of running the complete
# test.
testthat::skip_on_cran()
testthat::skip_on_ci()
familiar:::test_all_learners_train_predict_vimp(
learners = familiar:::.get_available_survival_regression_learners(show_general = FALSE))
familiar:::test_all_learners_parallel_train_predict_vimp(
learners = familiar:::.get_available_survival_regression_learners(show_general = FALSE))
# Create test data sets.
good_data <- familiar:::test_create_good_data("survival")
wide_data <- familiar:::test_create_wide_data("survival")
# Train the model using the good dataset.
good_model <- familiar:::test_train(
data = good_data,
cluster_method = "none",
imputation_method = "simple",
hyperparameter_list = list("sign_size" = familiar:::get_n_features(good_data)),
learner = "survival_regr_weibull")
# Train the model using wide data.
wide_model <- suppressWarnings(familiar:::test_train(
data = wide_data,
cluster_method = "none",
imputation_method = "simple",
hyperparameter_list = list("sign_size" = familiar:::get_n_features(wide_data)),
learner = "survival_regr_weibull"))
testthat::test_that("Survival regression model trained correctly", {
# Model trained
testthat::expect_equal(familiar:::model_is_trained(good_model), TRUE)
# Test the prediction type
testthat::expect_equal(
familiar:::get_prediction_type(good_model),
"expected_survival_time")
# Test that the model predicts hazard ratios
testthat::expect_equal(
familiar:::get_prediction_type(good_model, type = "survival_probability"),
"survival_probability")
# Checkt that no deprecation warnings are given.
familiar:::test_not_deprecated(good_model@messages$warning)
# Test that no errors appear.
testthat::expect_equal(good_model@messages$error, NULL)
})
testthat::test_that("Survival regression model has variable importance", {
# Extract the variable importance table.
vimp_table <- familiar:::get_vimp_table(good_model)
# Expect that the vimp table has three rows.
testthat::expect_equal(nrow(vimp_table), 3)
# Expect that the names are the same as that of the features.
testthat::expect_true(all(familiar:::get_feature_columns(good_data) %in% vimp_table$name))
# Expect that nodes has rank 1 and rx has rank 2.
testthat::expect_equal(vimp_table[rank == 1, ]$name, "nodes")
testthat::expect_equal(vimp_table[rank == 2, ]$name, "rx")
})
testthat::test_that("Survival regression model can train for wide data", {
# Model trained
testthat::expect_equal(familiar:::model_is_trained(wide_model), TRUE)
# With variable importance table.
testthat::expect_false(
familiar:::is_empty(familiar:::get_vimp_table(wide_model)))
# No valid predictions.
testthat::expect_true(familiar:::any_predictions_valid(
familiar:::.predict(wide_model, wide_data),
outcome_type = wide_data@outcome_type))
# No valid survival probability predictions.
testthat::expect_true(familiar:::any_predictions_valid(
familiar:::.predict(wide_model, wide_data, type = "survival_probability", time = 1000),
outcome_type = wide_data@outcome_type))
# Test that no deprecation warnings are given.
familiar:::test_not_deprecated(wide_model@messages$warning)
# Test that no errors appear.
testthat::expect_equal(wide_model@messages$error, NULL)
})
testthat::skip("Skip hyperparameter optimisation, unless manual.")
familiar:::test_hyperparameter_optimisation(
learners = familiar:::.get_available_survival_regression_learners(show_general = TRUE),
debug = FALSE,
parallel = FALSE
)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.