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


R rsample manual_rset 手動重采樣

manual_rset() 用於構造盡可能最小的 rset。當您擁有從 make_splits() 構建的自定義 rsplit 對象時,或者當您想要從現有 rset 中包含的拆分創建新的 rset 時,它會很有用。

用法

manual_rset(splits, ids)

參數

splits

"rsplit" 對象的列表。使用make_splits() 創建它們是最簡單的。

ids

id 的字符向量。 ids 的長度必須與 splits 的長度相同。

例子

df <- data.frame(x = c(1, 2, 3, 4, 5, 6))

# Create an rset from custom indices
indices <- list(
  list(analysis = c(1L, 2L), assessment = 3L),
  list(analysis = c(4L, 5L), assessment = 6L)
)

splits <- lapply(indices, make_splits, data = df)

manual_rset(splits, c("Split 1", "Split 2"))
#> # Manual resampling 
#> # A tibble: 2 × 2
#>   splits        id     
#>   <list>        <chr>  
#> 1 <split [2/1]> Split 1
#> 2 <split [2/1]> Split 2

# You can also use this to create an rset from a subset of an
# existing rset
resamples <- vfold_cv(mtcars)
best_split <- resamples[5, ]
manual_rset(best_split$splits, best_split$id)
#> # Manual resampling 
#> # A tibble: 1 × 2
#>   splits         id    
#>   <list>         <chr> 
#> 1 <split [29/3]> Fold05
源代碼:R/manual.R

相關用法


注:本文由純淨天空篩選整理自Hannah Frick等大神的英文原創作品 Manual resampling。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。