【问题标题】:Azure ML Batch Run - Single OutputAzure ML 批处理运行 - 单输出
【发布时间】:2016-11-25 05:19:58
【问题描述】:

我使用 R 引擎创建了一个预测实验。我的数据源是旋转的,因此我需要逐行传递。 输出非常适合单行预测。但是当我尝试填充多行时,它仍然提供单行输出 - 仅用于第一条记录。

我正在尝试按如下方式循环我的结果:

# Map 1-based optional input ports to variables
dataset1 <- maml.mapInputPort(1) # class: data.frame

library(forecast)
library(reshape)
library(dplyr)
library(zoo)
#exclude non required columns
my.ds <- dataset1[, -c(4,5,6)]
# set the CIs we want to use here, so we can reuse this vector
cis <- c(80, 95)

for (i in 1:nrow(my.ds)) {
my.start <- my.ds[i,c(3)]
my.product <- my.ds[i, "Product"]
my.location <- my.ds[i, "Location"]
my.result <- melt(my.ds[i,], id = c("Product","Location"))
my.ts <- ts(my.result$value, frequency=52, start=c(my.start,1))
# generate the forecast using those ci levels
f <- forecast(na.interp(my.ts), h=52, level=cis)
# make a data frame containing the forecast information, including the index
z <- as.data.frame(cbind(seq(1:52),
                       f$mean,
                       Reduce(cbind, lapply(seq_along(cis), function(i) cbind(f$lower[,i], f$upper[,i])))))
# give the columns better names
names(z) <- c("index", "mean", paste(rep(c("lower", "upper"), times = length(cis)), rep(cis, each = 2), sep = "."))
# manipulate the results as you describe
zw <- z %>%
# keep only the variable you want and its index
mutate(sssf = upper.95 - mean) %>%
select(index, mean, sssf) %>%
# add product and location info
mutate(product = my.product,
       location = my.location) %>%
# rearrange columns so it's easier to read
select(product, location, index, mean, sssf)
zw <- melt(zw, id.vars = c("product", "location", "index"), measure.vars = c("mean","sssf"))
data.set <- cast(zw, product + location ~ index + variable, value = "value")
# Select data.frame to be sent to the output Dataset port
maml.mapOutputPort("data.set");
}

这是我的实验设计:

这就是示例input 的样子:

我正在使用从实验站点下载的 Excel 测试工作簿进行测试。

【问题讨论】:

    标签: r forecasting azure-machine-learning-studio


    【解决方案1】:

    我发现了问题:

    {
    ...
    ds <- cast(zw, product + location ~ index + variable, value = "value")
    data.set <- rbind(data.set, ds)
    }
    # Select data.frame to be sent to the output Dataset port
    maml.mapOutputPort("data.set");
    

    我应该合并行,然后在循环之外输出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-28
      • 2012-12-18
      • 2018-08-27
      相关资源
      最近更新 更多