當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


R butcher axe-survreg.penal 取消監管處罰


survreg.penal 對象是從生存包。它們是從返回的survreg函數,代表擬合參數生存模型。

用法

# S3 method for survreg.penal
axe_call(x, verbose = FALSE, ...)

# S3 method for survreg.penal
axe_data(x, verbose = FALSE, ...)

# S3 method for survreg.penal
axe_env(x, verbose = FALSE, ...)

參數

x

一個模型對象。

verbose

每次執行 ax 方法時打印信息。記錄釋放了多少內存以及禁用了哪些函數。默認為 FALSE

...

與砍伐相關的任何其他參數。

刪除了 survreg 對象。

例子

# Load libraries
library(parsnip)
library(survival)

# Create model and fit
survreg_fit <- surv_reg(mode = "regression", dist = "weibull") %>%
  set_engine("survival") %>%
  fit(Surv(time, status) ~ rx, data = rats)

out <- butcher(survreg_fit, verbose = TRUE)
#> ✔ Memory released: 19.66 kB

# Another survreg.penal object
wrapped_survreg.penal <- function() {
  some_junk_in_environment <- runif(1e6)
  fit <- survreg(Surv(time, status) ~ rx,
                 data = rats, subset = (sex == "f"))
  return(fit)
}

# Remove junk
cleaned_sp <- axe_env(wrapped_survreg.penal(), verbose = TRUE)
#> ✔ Memory released: 8.09 MB

# Check size
lobstr::obj_size(cleaned_sp)
#> 13.74 kB
源代碼:R/survreg.penal.R

相關用法


注:本文由純淨天空篩選整理自Davis Vaughan等大神的英文原創作品 Axing an survreg.penal。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。