show_best()
顯示排名靠前的 sub-models 及其性能估計。
用法
show_best(x, ...)
# S3 method for default
show_best(x, ...)
# S3 method for tune_results
show_best(x, metric = NULL, n = 5, ...)
select_best(x, ...)
# S3 method for default
select_best(x, ...)
# S3 method for tune_results
select_best(x, metric = NULL, ...)
select_by_pct_loss(x, ...)
# S3 method for default
select_by_pct_loss(x, ...)
# S3 method for tune_results
select_by_pct_loss(x, ..., metric = NULL, limit = 2)
select_by_one_std_err(x, ...)
# S3 method for default
select_by_one_std_err(x, ...)
# S3 method for tune_results
select_by_one_std_err(x, ..., metric = NULL)
參數
- x
-
tune_grid()
或tune_bayes()
的結果。 - ...
-
對於
select_by_one_std_err()
和select_by_pct_loss()
,此參數直接傳遞給dplyr::arrange()
,以便用戶可以對模型從最簡單到最複雜進行排序。也就是說,對於參數p
,如果p
的值較小表示模型較簡單,則傳遞不帶引號的表達式p
;如果值較大表示模型較簡單,則傳遞desc(p)
。這兩項函數至少需要一項。請參閱下麵的示例。 - metric
-
將用於對模型進行排序的指標的字符值。 (有關更多詳細信息,請參閱https://yardstick.tidymodels.org/articles/metric-types.html)。如果
x
中存在單個指標,則不需要。如果有多個指標但沒有給出,則使用指標集中的第一個指標(並發出警告)。 - n
-
要返回的頂部結果/行數的整數。
- limit
-
可接受的性能損失限製(以百分比為單位)。請參閱下麵的詳細信息。
細節
select_best()
找到具有最佳性能值的調整參數組合。
select_by_one_std_err()
使用“one-standard 誤差規則”(Breiman _el at,1984),該規則選擇在數值最優結果的一個標準誤差範圍內的最簡單模型。
select_by_pct_loss()
選擇最簡單的模型,其性能損失在某個可接受的範圍內。
對於損失百分比,假設最佳模型的 RMSE 為 0.75,更簡單的模型的 RMSE 為 1。損失百分比為 (1.00 - 0.75)/1.00 * 100
或 25%。請注意,損失始終為非負數。
例子
data("example_ames_knn")
show_best(ames_iter_search, metric = "rmse")
#> # A tibble: 5 × 12
#> K weight_func dist_power lon lat .metric .estimator mean n
#> <int> <chr> <dbl> <int> <int> <chr> <chr> <dbl> <int>
#> 1 33 triweight 0.511 10 3 rmse standard 0.0728 10
#> 2 5 rank 0.411 2 7 rmse standard 0.0740 10
#> 3 21 triweight 0.909 10 4 rmse standard 0.0742 10
#> 4 21 cos 0.626 1 4 rmse standard 0.0746 10
#> 5 19 inv 0.117 1 4 rmse standard 0.0758 10
#> # ℹ 3 more variables: std_err <dbl>, .config <chr>, .iter <int>
select_best(ames_iter_search, metric = "rsq")
#> # A tibble: 1 × 6
#> K weight_func dist_power lon lat .config
#> <int> <chr> <dbl> <int> <int> <chr>
#> 1 33 triweight 0.511 10 3 Preprocessor10_Model1
# To find the least complex model within one std error of the numerically
# optimal model, the number of nearest neighbors are sorted from the largest
# number of neighbors (the least complex class boundary) to the smallest
# (corresponding to the most complex model).
select_by_one_std_err(ames_grid_search, metric = "rmse", desc(K))
#> # A tibble: 1 × 13
#> K weight_func dist_power lon lat .metric .estimator mean n
#> <int> <chr> <dbl> <int> <int> <chr> <chr> <dbl> <int>
#> 1 33 triweight 0.511 10 3 rmse standard 0.0728 10
#> # ℹ 4 more variables: std_err <dbl>, .config <chr>, .best <dbl>,
#> # .bound <dbl>
# Now find the least complex model that has no more than a 5% loss of RMSE:
select_by_pct_loss(
ames_grid_search,
metric = "rmse",
limit = 5, desc(K)
)
#> # A tibble: 1 × 13
#> K weight_func dist_power lon lat .metric .estimator mean n
#> <int> <chr> <dbl> <int> <int> <chr> <chr> <dbl> <int>
#> 1 33 triweight 0.511 10 3 rmse standard 0.0728 10
#> # ℹ 4 more variables: std_err <dbl>, .config <chr>, .best <dbl>,
#> # .loss <dbl>
相關用法
- R tune coord_obs_pred 對觀察值與預測值的繪圖使用相同的比例
- R tune extract-tune 提取調整對象的元素
- R tune filter_parameters 刪除一些調整參數結果
- R tune fit_best 將模型擬合到數值最優配置
- R tune conf_mat_resampled 計算重采樣的平均混淆矩陣
- R tune finalize_model 將最終參數拚接到對象中
- R tune tune_bayes 模型參數的貝葉斯優化。
- R tune collect_predictions 獲取並格式化由調整函數產生的結果
- R tune expo_decay 指數衰減函數
- R tune fit_resamples 通過重采樣擬合多個模型
- R tune merge.recipe 將參數網格值合並到對象中
- R tune autoplot.tune_results 繪圖調整搜索結果
- R tune tune_grid 通過網格搜索進行模型調整
- R tune dot-use_case_weights_with_yardstick 確定案例權重是否應傳遞至標準
- R tune message_wrap 寫一條尊重線寬的消息
- R tune prob_improve 用於對參數組合進行評分的獲取函數
- R tune last_fit 將最終的最佳模型擬合到訓練集並評估測試集
- R update_PACKAGES 更新現有的 PACKAGES 文件
- R textrecipes tokenlist 創建令牌對象
- R themis smotenc SMOTENC算法
- R print.via.format 打印實用程序
- R tibble tibble 構建 DataFrame 架
- R tidyr separate_rows 將折疊的列分成多行
- R textrecipes step_lemma 標記變量的詞形還原
- R textrecipes show_tokens 顯示配方的令牌輸出
注:本文由純淨天空篩選整理自Max Kuhn等大神的英文原創作品 Investigate best tuning parameters。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。