R语言recipes包 bake函数使用说明

您所在的位置:网站首页 bake和cake哪个好 R语言recipes包 bake函数使用说明

R语言recipes包 bake函数使用说明

2024-07-14 06:22| 来源: 网络整理| 查看: 265

返回R语言recipes包函数列表

功能\作用概述:

对于至少有一个经过训练的预处理操作的配方byprep.配方(),将计算应用于新数据。

语法\用法:

bake(object, ...)

## S3 method for class 'recipe'bake(object, new_data, ..., composition = "tibble")

参数说明:

object : 一个经过训练的对象,例如至少有一个预处理操作的recipe()。

... : 一个或多个选择器函数,用于选择该函数将转换哪些变量。有关详细信息,请参见selections()详细信息。如果没有给定选择器,默认值是useverything()。

new_data : 对其进行预处理的数据帧或数据块。如果//oraprdnt为NULL,则返回预处理的trainingdata(假设使用了prep(retain=TRUE))。

composition : “tibble”、“matrix”或“matrix”数据框,或“dgCMatrix”,表示已处理数据集的格式。请注意,烘焙过程中的所有计算都是以非稀疏格式完成的。另外,请注意,此参数应在任何选择器之后调用,并且选择器应仅限于数值列(否则会引发错误)。

示例\实例:

data(ames, package = "modeldata")

ames < - mutate(ames, Sale_Price = log10(Sale_Price))

ames_rec < - recipe(Sale_Price ~ ., data = ames[-(1:6), ]) %>% step_other(Neighborhood, threshold = 0.05) %>% step_dummy(all_nominal()) %>% step_interact(~ starts_with("Central_Air"):Year_Built) %>% step_ns(Longitude, Latitude, deg_free = 2) %>% step_zv(all_predictors()) %>% prep()

# return the training set (already embedded in ames_rec)ames_train < - bake(ames_rec, new_data = NULL)

# apply processing to other data:ames_new < - bake(ames_rec, new_data = head(ames))



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3