使用邏輯回歸模型來校準概率
用法
cal_estimate_logistic(
.data,
truth = NULL,
estimate = dplyr::starts_with(".pred_"),
smooth = TRUE,
parameters = NULL,
...
)
# S3 method for data.frame
cal_estimate_logistic(
.data,
truth = NULL,
estimate = dplyr::starts_with(".pred_"),
smooth = TRUE,
parameters = NULL,
...,
.by = NULL
)
# S3 method for tune_results
cal_estimate_logistic(
.data,
truth = NULL,
estimate = dplyr::starts_with(".pred_"),
smooth = TRUE,
parameters = NULL,
...
)
# S3 method for grouped_df
cal_estimate_logistic(
.data,
truth = NULL,
estimate = NULL,
smooth = TRUE,
parameters = NULL,
...
)
參數
- .data
-
未分組的
data.frame
對象或tune_results
對象,包含預測和概率列。 - truth
-
真實類別結果的列標識符(即一個因子)。這應該是一個不帶引號的列名。
- estimate
-
列標識符向量,或
dplyr
選擇器函數之一,用於選擇哪些變量包含類概率。它默認為 tidymodels 使用的前綴 (.pred_
)。標識符的順序將被視為與truth
變量的級別順序相同。 - smooth
-
適用於物流模型。當
TRUE
時,它在邏輯樣條曲線之間切換;當FALSE
時,它在簡單邏輯回歸之間切換。 - parameters
-
(可選)可選的調整參數值小標題,可用於在處理之前過濾預測值。僅適用於
tune_results
對象。 - ...
-
傳遞給用於計算新概率的模型或例程的附加參數。
- .by
-
分組變量的列標識符。這應該是一個不帶引號的列名稱,用於選擇用於分組的定性變量。默認為
NULL
。當.by = NULL
時,不會進行分組。
細節
該函數使用其他包中的現有建模函數來創建校準:
-
當
smooth
設置為FALSE
時,使用stats::glm()
-
當
smooth
設置為TRUE
時,使用mgcv::gam()
多類擴展
該方法尚未擴展到多類結果。然而,自然的多類擴展是 cal_estimate_multinomial()
。
例子
# It will automatically identify the probability columns
# if passed a model fitted with tidymodels
cal_estimate_logistic(segment_logistic, Class)
#>
#> ── Probability Calibration
#> Method: Generalized additive model
#> 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_logistic(segment_logistic, Class, c(.pred_poor, .pred_good))
#>
#> ── Probability Calibration
#> Method: Generalized additive model
#> 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_logistic(segment_logistic, Class, dplyr::starts_with(".pred_"))
#>
#> ── Probability Calibration
#> Method: Generalized additive model
#> Type: Binary
#> Source class: Data Frame
#> Data points: 1,010
#> Truth variable: `Class`
#> Estimate variables:
#> `.pred_good` ==> good
#> `.pred_poor` ==> poor
相關用法
- R probably cal_estimate_linear 使用線性回歸模型來校準數值預測
- R probably cal_estimate_multinomial 使用多項校準模型來計算新的概率
- R probably cal_estimate_beta 使用 Beta 校準模型來計算新概率
- R probably cal_estimate_isotonic 使用等滲回歸模型來校準模型預測。
- R probably cal_estimate_isotonic_boot 使用引導等滲回歸模型來校準概率
- R probably cal_plot_logistic 通過邏輯回歸繪製概率校準圖
- R probably cal_plot_breaks 通過分箱繪製概率校準圖
- R probably cal_validate_logistic 使用和不使用邏輯校準來測量性能
- R probably cal_validate_isotonic_boot 使用和不使用袋裝等滲回歸校準來測量性能
- R probably cal_plot_regression 回歸校準圖
- R probably cal_validate_multinomial 使用和不使用多項式校準來測量性能
- R probably cal_apply 對一組現有預測應用校準
- R probably cal_validate_linear 使用和不使用線性回歸校準來測量性能
- R probably cal_plot_windowed 通過移動窗口繪製概率校準圖
- R probably cal_validate_isotonic 使用和不使用等滲回歸校準來測量性能
- R probably cal_validate_beta 使用和不使用 Beta 校準來測量性能
- R probably class_pred 創建類別預測對象
- R probably append_class_pred 添加 class_pred 列
- R probably threshold_perf 生成跨概率閾值的性能指標
- R probably as_class_pred 強製轉換為 class_pred 對象
- R probably levels.class_pred 提取class_pred級別
- R probably locate-equivocal 找到模棱兩可的值
- R probably int_conformal_quantile 通過保形推理和分位數回歸預測區間
- R probably make_class_pred 根據類概率創建 class_pred 向量
- R probably reportable_rate 計算報告率
注:本文由純淨天空篩選整理自Max Kuhn等大神的英文原創作品 Uses a logistic regression model to calibrate probabilities。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。