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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。