我在 Azure ML Studio 中创建了一个预测因果模型,用于确定组织在 2015 年每个月的招聘需求。由于它是一个因果模型,我单独预测 2015 年的所有参数并将它们提供给我的模型。
其中一个因素是前 9 个月的雇佣价值。这意味着如果我预测 2015 年 1 月的租用价值,将考虑前 9 个月的租用价值(2014 年 12 月 - 2014 年 4 月)。
以下是我的参数集:
Year Month Factor A Factor B Factor C Factor D Prev. Month-1 Prev. Month-2 Prev. Month-3 Prev. Month-4 Prev. Month-5 Prev. Month-6 Prev. Month-7 Prev. Month-8 Prev. Month-9
样本输入:
Year Month Factor A Factor B Factor C Factor D Prev. Month-1 Prev. Month-2 Prev. Month-3 Prev. Month-4 Prev. Month-5 Prev. Month-6 Prev. Month-7 Prev. Month-8 Prev. Month-9
2015 1 2 4 6 8 10 11 12 13 14 15 16 17 18
运行模型后,我得到了预测雇用(分数标签)作为我的输出:
Year Month Factor A Factor B Factor C Factor D Prev. Month-1 Prev. Month-2 Prev. Month-3 Prev. Month-4 Prev. Month-5 Prev. Month-6 Prev. Month-7 Prev. Month-8 Prev. Month-9 Score Labels
2015 1 2 4 6 8 10 11 12 13 14 15 16 17 18 19
对于 2015 年 2 月的预测,1 月的预测值变为 Prev。第 1 个月的值。
Year Month Factor A Factor B Factor C Factor D Prev. Month-1 Prev. Month-2 Prev. Month-3 Prev. Month-4 Prev. Month-5 Prev. Month-6 Prev. Month-7 Prev. Month-8 Prev. Month-9
2015 1 2 4 6 8 10 11 12 13 14 15 16 17 18
2015 2 3 5 7 9 19 10 11 12 13 14 15 16 17
这变得有点乏味,因为我必须重复 12 次 - 每个月一次。有人可以建议我如何使用 R 脚本解决它吗?这是我到目前为止所写的:
dataset <- maml.mapInputPort(1)
previous <- 9
orig_names <- names(dataset)
n_rows <- dim(dataset)[1]
base <- 9
for (i in 1:previous) {
dataset[(i+1):n_rows,base+i] <- dataset[1:(n_rows-i),base]
dataset[1:i,base+i] <- dataset[1:i,base+i-1]
}
a <- -1:-previous
new_names <- paste("Prev. Month",a)
names(dataset) <- c(orig_names,new_names)
maml.mapOutputPort("dataset")
谢谢。
更新 1
我已经设法在 Azure 中循环执行我的模型。对于每次迭代,我需要提供输入参数(例如二月)。
有人可以帮助我如何获取“分数标签”下的预测并将其作为“上一月-1”下的参数附加到我在 R 中下个月的输入吗?