Skip to content

Commit

Permalink
tests-pass
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmayer committed Aug 8, 2024
1 parent 81c4a28 commit 6be9787
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/greedyOpt.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ greedyMSE <- function(X, Y, max_iter = 100L) {
print.greedyMSE <- function(x, ...) {
cat("Greedy MSE\n")
cat("RMSE: ", x$RMSE, "\n")
cat("model_weights:\n")
cat("Weights:\n")
print(x$model_weights)
}

Expand Down
Binary file modified coverage.rds
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/testthat/test-greedyMSE.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ testthat::test_that("greedyMSE works for regression", {
testthat::expect_lt(model$RMSE, stats::sd(regression_data$Y)) # Model should be better than baseline
# High correlation with true values
testthat::expect_gt(stats::cor(predict(model, regression_data$X), regression_data$Y), 0.8)

testthat::expect_output(print(model), "Greedy MSE")
testthat::expect_output(print(model), "RMSE")
testthat::expect_output(print(model), "Weights")
})

# Test for binary classification (one col)
Expand All @@ -46,6 +50,10 @@ testthat::test_that("greedyMSE works for binary classification", {
predictions <- predict(model, regression_data$X)
accuracy <- mean((predictions > 0.5) == Y_binary)
testthat::expect_gt(accuracy, 0.7) # Accuracy should be better than random guessing

testthat::expect_output(print(model), "Greedy MSE")
testthat::expect_output(print(model), "RMSE")
testthat::expect_output(print(model), "Weights")
})

# Test for multiple regression (many cols)
Expand Down

0 comments on commit 6be9787

Please sign in to comment.