Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中使用配方后,如何取消(反变换)变量的规范化?_R_Machine Learning_R Caret - Fatal编程技术网

在R中使用配方后,如何取消(反变换)变量的规范化?

在R中使用配方后,如何取消(反变换)变量的规范化?,r,machine-learning,r-caret,R,Machine Learning,R Caret,我正在使用train功能训练neuralnet,并使用配方对数据进行预处理 是否有任何功能可以从模型中进行预测,然后在原始范围内重新缩放它们,在我的例子中是[1100] 库(插入符号) 图书馆(食谱) 图书馆(neuralnet) #创建数据集-时间表 tt如果使用step\u normalize而不是step\u scale和step\u center,则可以根据配方使用以下函数“取消规范化”。(如果希望通过两个步骤进行规范化,则需要调整非规范化功能。) 此函数用于提取相关步骤 #' Extr

我正在使用
train
功能训练
neuralnet
,并使用
配方对数据进行预处理

是否有任何功能可以从模型中进行预测,然后在原始范围内重新缩放它们,在我的例子中是
[1100]

库(插入符号)
图书馆(食谱)
图书馆(neuralnet)
#创建数据集-时间表

tt如果使用
step\u normalize
而不是
step\u scale
step\u center
,则可以根据
配方使用以下函数“取消规范化”。(如果希望通过两个步骤进行规范化,则需要调整
非规范化功能。)

此函数用于提取相关步骤

#' Extract step item
#'
#' Returns extracted step item from prepped recipe.
#'
#' @param recipe Prepped recipe object.
#' @param step Step from prepped recipe.
#' @param item Item from prepped recipe.
#' @param enframe Should the step item be enframed?
#'
#' @export
extract_step_item <- function(recipe, step, item, enframe = TRUE) {
  d <- recipe$steps[[which(purrr::map_chr(recipe$steps, ~ class(.)[1]) == step)]][[item]]
  if (enframe) {
    tibble::enframe(d) %>% tidyr::spread(key = 1, value = 2)
  } else {
    d
  }
}


其中,
predictions
是从训练模型生成的预测向量,
prepped\u recipe\u obj
在您的情况下是
rec\u reg
,而
outcome\u var\u name
在您的情况下是
产品
如果您使用
步骤规范化
而不是
步骤尺度和
步骤中心
,根据
配方
,可以使用以下函数“取消规格化”。(如果希望通过两个步骤进行规范化,则需要调整
非规范化功能。)

此函数用于提取相关步骤

#' Extract step item
#'
#' Returns extracted step item from prepped recipe.
#'
#' @param recipe Prepped recipe object.
#' @param step Step from prepped recipe.
#' @param item Item from prepped recipe.
#' @param enframe Should the step item be enframed?
#'
#' @export
extract_step_item <- function(recipe, step, item, enframe = TRUE) {
  d <- recipe$steps[[which(purrr::map_chr(recipe$steps, ~ class(.)[1]) == step)]][[item]]
  if (enframe) {
    tibble::enframe(d) %>% tidyr::spread(key = 1, value = 2)
  } else {
    d
  }
}


其中,
predictions
是从训练模型生成的预测向量,
prepped_recipe_obj
在您的案例中是
rec_reg
,而
outcome_var_name
在您的案例中是
产品

您可能也感兴趣。您也可能对。
unnormalize(predictions, prepped_recipe_obj, outcome_var_name)