refresh_blueprint()
是麵向開發人員的通用函數,在 update_blueprint()
末尾調用。它隻是特定於方法的 new_*_blueprint()
函數的包裝,該函數再次通過構造函數運行更新後的藍圖,以確保藍圖的所有元素在更新後仍然有效。
例子
blueprint <- default_xy_blueprint()
# This should never be done manually, but is essentially
# what `update_blueprint(blueprint, intercept = TRUE)` does for you
blueprint$intercept <- TRUE
# Then update_blueprint() will call refresh_blueprint()
# to ensure that the structure is correct
refresh_blueprint(blueprint)
#> XY blueprint:
#>
#> # Predictors: 0
#> # Outcomes: 0
#> Intercept: TRUE
#> Novel Levels: FALSE
#> Composition: tibble
# So you can't do something like...
blueprint_bad <- blueprint
blueprint_bad$intercept <- 1
# ...because the constructor will catch it
try(refresh_blueprint(blueprint_bad))
#> Error in new_blueprint(intercept = intercept, allow_novel_levels = allow_novel_levels, :
#> `intercept` must be `TRUE` or `FALSE`, not the number 1.
# And update_blueprint() catches this automatically
try(update_blueprint(blueprint, intercept = 1))
#> Error in new_blueprint(intercept = intercept, allow_novel_levels = allow_novel_levels, :
#> `intercept` must be `TRUE` or `FALSE`, not the number 1.
相關用法
- R hardhat run-mold 根據藍圖 Mold()
- R hardhat run-forge 根據藍圖 forge()
- R hardhat validate_prediction_size 確保預測具有正確的行數
- R hardhat default_recipe_blueprint 默認配方藍圖
- R hardhat is_blueprint x 是預處理藍圖嗎?
- R hardhat validate_column_names 確保數據包含所需的列名
- R hardhat default_formula_blueprint 默認公式藍圖
- R hardhat update_blueprint 更新預處理藍圖
- R hardhat weighted_table 加權表
- R hardhat validate_outcomes_are_univariate 確保結果是單變量
- R hardhat get_levels 從 DataFrame 中提取因子水平
- R hardhat add_intercept_column 向數據添加截距列
- R hardhat is_frequency_weights x 是頻率權重向量嗎?
- R hardhat model_offset 提取模型偏移
- R hardhat standardize 標準化結果
- R hardhat model_matrix 構建設計矩陣
- R hardhat is_importance_weights x 是重要性權重向量嗎?
- R hardhat get_data_classes 從 DataFrame 或矩陣中提取數據類
- R hardhat fct_encode_one_hot 將一個因子編碼為 one-hot 指標矩陣
- R hardhat new_frequency_weights 構建頻率權重向量
- R hardhat validate_no_formula_duplication 確保公式中不出現重複項
- R hardhat default_xy_blueprint 默認 XY 藍圖
- R hardhat shrink 僅對所需列進行子集化
- R hardhat validate_outcomes_are_numeric 確保結果都是數字
- R hardhat scream ? 尖叫。
注:本文由純淨天空篩選整理自Davis Vaughan等大神的英文原創作品 Refresh a preprocessing blueprint。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。