可以使用 Barber 等人 (2018) 說明的 CV+ 保形推理方法來計算擬合回歸工作流對象的非參數預測區間。
用法
int_conformal_cv(object, ...)
# S3 method for default
int_conformal_cv(object, ...)
# S3 method for resample_results
int_conformal_cv(object, ...)
# S3 method for tune_results
int_conformal_cv(object, parameters, ...)
參數
- object
-
來自 tidymodels 重采樣或調整函數的對象,例如
tune::fit_resamples()
、tune::tune_grid()
或類似函數。該對象的生成方式應使.extracts
列包含每次重采樣的擬合工作流程(請參閱下麵的詳細信息)。 - ...
-
目前未使用。
- parameters
-
調整參數值的小標題,可用於在處理之前過濾預測值。此 tibble 應從調整結果中選擇一組 hyper-parameter 值。僅當將調整對象傳遞給
object
時才需要這樣做。
值
"int_conformal_cv"
類的對象,包含創建間隔的信息。 predict()
方法用於生成間隔。
細節
該函數實現了 Barber at al (2018) 第 3 節中的 CV+ 方法。它使用重采樣模型擬合及其相關的保留殘差來為回歸模型製定預測區間。
該函數為計算準備對象。 predict()
方法計算新數據的間隔。
此方法是為 V-fold 交叉驗證(無重複)而開發的。對於任何其他重采樣方法,間隔覆蓋都是未知的。該函數不會停止其他類型重采樣的計算,但我們無法知道結果是否合適。
參考
Rina Foygel Barber、Emmanuel J. Candès、Aaditya Ramdas、Ryan J. Tibshirani“使用折刀+進行預測推理”,《統計年鑒》,49(1), 486-507, 2021
例子
library(workflows)
library(dplyr)
library(parsnip)
library(rsample)
library(tune)
library(modeldata)
set.seed(2)
sim_train <- sim_regression(200)
sim_new <- sim_regression( 5) %>% select(-outcome)
sim_rs <- vfold_cv(sim_train)
# We'll use a neural network model
mlp_spec <-
mlp(hidden_units = 5, penalty = 0.01) %>%
set_mode("regression")
# Use a control function that saves the predictions as well as the models.
# Consider using the butcher package in the extracts function to have smaller
# object sizes
ctrl <- control_resamples(save_pred = TRUE, extract = I)
set.seed(3)
nnet_res <-
mlp_spec %>%
fit_resamples(outcome ~ ., resamples = sim_rs, control = ctrl)
nnet_int_obj <- int_conformal_cv(nnet_res)
nnet_int_obj
#> Conformal inference via CV+
#> preprocessor: formula
#> model: mlp (engine = nnet)
#> number of models: 10
#> training set size: 200
#>
#> Use `predict(object, new_data, level)` to compute prediction intervals
predict(nnet_int_obj, sim_new)
#> # A tibble: 5 × 3
#> .pred_lower .pred .pred_upper
#> <dbl> <dbl> <dbl>
#> 1 3.67 42.8 81.9
#> 2 -29.6 9.47 48.6
#> 3 -14.6 24.5 63.6
#> 4 -39.2 -0.0793 39.0
#> 5 -11.1 28.0 67.1
相關用法
- R probably int_conformal_quantile 通過保形推理和分位數回歸預測區間
- R probably int_conformal_split 通過分割共形推理預測區間
- R probably is_class_pred 測試對象是否繼承自class_pred
- R probably append_class_pred 添加 class_pred 列
- R probably cal_plot_logistic 通過邏輯回歸繪製概率校準圖
- R probably class_pred 創建類別預測對象
- R probably cal_plot_breaks 通過分箱繪製概率校準圖
- R probably cal_estimate_multinomial 使用多項校準模型來計算新的概率
- R probably cal_validate_logistic 使用和不使用邏輯校準來測量性能
- R probably cal_validate_isotonic_boot 使用和不使用袋裝等滲回歸校準來測量性能
- R probably threshold_perf 生成跨概率閾值的性能指標
- R probably cal_estimate_beta 使用 Beta 校準模型來計算新概率
- R probably cal_plot_regression 回歸校準圖
- R probably as_class_pred 強製轉換為 class_pred 對象
- R probably levels.class_pred 提取class_pred級別
- R probably cal_estimate_isotonic 使用等滲回歸模型來校準模型預測。
- R probably locate-equivocal 找到模棱兩可的值
- R probably cal_estimate_logistic 使用邏輯回歸模型來校準概率
- R probably cal_validate_multinomial 使用和不使用多項式校準來測量性能
- R probably make_class_pred 根據類概率創建 class_pred 向量
- R probably cal_apply 對一組現有預測應用校準
- R probably reportable_rate 計算報告率
- R probably cal_validate_linear 使用和不使用線性回歸校準來測量性能
- R probably cal_estimate_isotonic_boot 使用引導等滲回歸模型來校準概率
- R probably cal_plot_windowed 通過移動窗口繪製概率校準圖
注:本文由純淨天空篩選整理自Max Kuhn等大神的英文原創作品 Prediction intervals via conformal inference CV+。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。