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


R probably cal_estimate_isotonic_boot 使用引導等滲回歸模型來校準概率

使用引導等滲回歸模型來校準概率

用法

cal_estimate_isotonic_boot(
  .data,
  truth = NULL,
  estimate = dplyr::starts_with(".pred"),
  times = 10,
  parameters = NULL,
  ...
)

# S3 method for data.frame
cal_estimate_isotonic_boot(
  .data,
  truth = NULL,
  estimate = dplyr::starts_with(".pred"),
  times = 10,
  parameters = NULL,
  ...,
  .by = NULL
)

# S3 method for tune_results
cal_estimate_isotonic_boot(
  .data,
  truth = NULL,
  estimate = dplyr::starts_with(".pred"),
  times = 10,
  parameters = NULL,
  ...
)

# S3 method for grouped_df
cal_estimate_isotonic_boot(
  .data,
  truth = NULL,
  estimate = NULL,
  times = 10,
  parameters = NULL,
  ...
)

參數

.data

未分組的 data.frame 對象或 tune_results 對象,包含預測和概率列。

truth

真實類別結果的列標識符(即一個因子)。這應該是一個不帶引號的列名。

estimate

列標識符向量,或 dplyr 選擇器函數之一,用於選擇哪些變量包含類概率。它默認為 tidymodels 使用的前綴 ( .pred_ )。標識符的順序將被視為與 truth 變量的級別順序相同。

times

引導程序的數量。

parameters

(可選)可選的調整參數值小標題,可用於在處理之前過濾預測值。僅適用於tune_results 對象。

...

傳遞給用於計算新概率的模型或例程的附加參數。

.by

分組變量的列標識符。這應該是一個不帶引號的列名稱,用於選擇用於分組的定性變量。默認為 NULL 。當.by = NULL時,不會進行分組。

細節

該函數使用stats::isoreg()來創建獲取校準值。它多次運行 stats::isoreg(),並且每次都使用不同的種子。結果保存在返回的 cal_object 中。

多類擴展

此方法設計用於兩個類。對於多類,它為每個類創建一組“一對一”校準。將它們應用於數據後,概率估計值會重新歸一化以加一。最後一步可能會影響校準。

也可以看看

https://www.tidymodels.org/learn/models/calibration/, cal_validate_isotonic_boot()

例子

# It will automatically identify the probability columns
# if passed a model fitted with tidymodels
cal_estimate_isotonic_boot(segment_logistic, Class)
#> 
#> ── Probability Calibration 
#> Method: Bootstrapped isotonic regression
#> Type: Binary
#> Source class: Data Frame
#> Data points: 1,010
#> Truth variable: `Class`
#> Estimate variables:
#> `.pred_good` ==> good
#> `.pred_poor` ==> poor
# Specify the variable names in a vector of unquoted names
cal_estimate_isotonic_boot(segment_logistic, Class, c(.pred_poor, .pred_good))
#> 
#> ── Probability Calibration 
#> Method: Bootstrapped isotonic regression
#> Type: Binary
#> Source class: Data Frame
#> Data points: 1,010
#> Truth variable: `Class`
#> Estimate variables:
#> `.pred_good` ==> good
#> `.pred_poor` ==> poor
# dplyr selector functions are also supported
cal_estimate_isotonic_boot(segment_logistic, Class, dplyr::starts_with(".pred"))
#> 
#> ── Probability Calibration 
#> Method: Bootstrapped isotonic regression
#> Type: Binary
#> Source class: Data Frame
#> Data points: 1,010
#> Truth variable: `Class`
#> Estimate variables:
#> `.pred_good` ==> good
#> `.pred_poor` ==> poor

相關用法


注:本文由純淨天空篩選整理自Max Kuhn等大神的英文原創作品 Uses a bootstrapped Isotonic regression model to calibrate probabilities。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。