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


R probably cal_estimate_isotonic 使用等滲回歸模型來校準模型預測。

使用等滲回歸模型來校準模型預測。

用法

cal_estimate_isotonic(
  .data,
  truth = NULL,
  estimate = dplyr::starts_with(".pred"),
  parameters = NULL,
  ...
)

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

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

# S3 method for grouped_df
cal_estimate_isotonic(
  .data,
  truth = NULL,
  estimate = NULL,
  parameters = NULL,
  ...
)

參數

.data

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

truth

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

estimate

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

parameters

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

...

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

.by

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

細節

此函數使用stats::isoreg() 創建獲取二元分類或數值回歸的校準值。

多類擴展

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

參考

比安卡·紮德羅茲尼和查爾斯·埃爾坎。 (2002)。將分類器分數轉換為準確的多類概率估計。 ACM SIGKDD 知識發現和數據挖掘國際會議論文集。

也可以看看

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

例子

# ------------------------------------------------------------------------------
# Binary Classification

# It will automatically identify the probability columns
# if passed a model fitted with tidymodels
cal_estimate_isotonic(segment_logistic, Class)
#> 
#> ── Probability Calibration 
#> Method: Isotonic regression
#> Type: Binary
#> Source class: Data Frame
#> Data points: 1,010
#> Unique Predicted Values: 86
#> Truth variable: `Class`
#> Estimate variables:
#> `.pred_good` ==> good
#> `.pred_poor` ==> poor

# Specify the variable names in a vector of unquoted names
cal_estimate_isotonic(segment_logistic, Class, c(.pred_poor, .pred_good))
#> 
#> ── Probability Calibration 
#> Method: Isotonic regression
#> Type: Binary
#> Source class: Data Frame
#> Data points: 1,010
#> Unique Predicted Values: 187
#> Truth variable: `Class`
#> Estimate variables:
#> `.pred_good` ==> good
#> `.pred_poor` ==> poor

# dplyr selector functions are also supported
cal_estimate_isotonic(segment_logistic, Class, dplyr::starts_with(".pred_"))
#> 
#> ── Probability Calibration 
#> Method: Isotonic regression
#> Type: Binary
#> Source class: Data Frame
#> Data points: 1,010
#> Unique Predicted Values: 84
#> Truth variable: `Class`
#> Estimate variables:
#> `.pred_good` ==> good
#> `.pred_poor` ==> poor

# ------------------------------------------------------------------------------
# Regression (numeric outcomes)

cal_estimate_isotonic(boosting_predictions_oob, outcome, .pred)
#> 
#> ── Probability Calibration 
#> Method: Isotonic regression
#> Type: Regression
#> Source class: Data Frame
#> Data points: 2,000
#> Unique Predicted Values: 42
#> Truth variable: `outcome`
#> Estimate variables:
#> `.pred` ==> predictions

相關用法


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