Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove print._coxnet() #313

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Imports:
hardhat (>= 1.1.0),
lifecycle,
mboost,
prettyunits,
prodlim (>= 2023.03.31),
purrr,
rlang (>= 1.0.0),
Expand All @@ -56,4 +55,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.0
RoxygenNote: 7.3.1
16 changes: 4 additions & 12 deletions R/proportional_hazards-glmnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,11 @@ check_dots_coxnet <- function(x, call = caller_env()) {

#' @export
print._coxnet <- function(x, ...) {
cat("parsnip model object\n\n")
cat("Fit time: ", prettyunits::pretty_sec(x$elapsed[["elapsed"]]), "\n")

if (inherits(x$fit, "try-error")) {
cat("Model fit failed with error:\n", x$fit, "\n")
} else {
print(x$fit, ...)
cat("The training data has been saved for prediction.\n")
}
NextMethod(print, x)
cat("The training data has been saved for prediction.\n")
invisible(x)
}


# prediction --------------------------------------------------------------

coxnet_prepare_x <- function(new_data, object) {
Expand Down Expand Up @@ -462,7 +454,7 @@ multi_predict_coxnet_linear_pred <- function(object, new_data, opts, penalty) {
# prediction: time --------------------------------------------------------

#' A wrapper for survival times with coxnet models
#' @param object A parsnip `model_fit` object resulting from
#' @param object A parsnip `model_fit` object resulting from
#' [proportional_hazards() with engine = "glmnet"][parsnip::details_proportional_hazards_glmnet].
#' @param new_data Data for prediction.
#' @param penalty Penalty value(s).
Expand Down Expand Up @@ -584,7 +576,7 @@ get_missings_coxnet <- function(new_x, new_strata) {


#' A wrapper for survival probabilities with coxnet models
#' @param object A parsnip `model_fit` object resulting from
#' @param object A parsnip `model_fit` object resulting from
#' [proportional_hazards() with engine = "glmnet"][parsnip::details_proportional_hazards_glmnet].
#' @param new_data Data for prediction.
#' @param eval_time A vector of integers for prediction times.
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/_snaps/proportional_hazards-glmnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Output
parsnip model object

Fit time: NA

Call: glmnet::glmnet(x = data_obj$x, y = data_obj$y, family = "cox", weights = weights, alpha = alpha, lambda = lambda)

Expand Down
Loading