gpt4 book ai didi

r - 自定义模块的多个输出

转载 作者:行者123 更新时间:2023-12-03 03:03:44 24 4
gpt4 key购买 nike

This Microsoft Azure documentation演示如何为 Azure 机器学习工作室创作自定义模块。有一段关于从模块返回多个输出的内容。然而,按照说明,我只能在第一个输出端口的可视化中看到数据,而其他输出端口仍为空。

这是 this one 的后续问题。我接受了那里的答案,因为我误解了我编写的自定义模块的结果 - 某些输出端口可能为空,并且我仓促地假设输出是正确的。然而,在 RStudio 中运行相同的代码确实会生成本应在 ML Studio 中返回的数据。此外,打印数据也有效。

最小示例:

模块的 ZIP 文件中包含的源文件:

测试.R

foo <- function() {
require(data.table)
out1 <- data.table(mtcars)
out2 <- data.table(cars)

print("out1:")
print(head(out1))
print("out2:")
print(head(out2))

return(list(out1, out2))
}

测试.xml

<Module name="Multiple outputs">
<Owner>...</Owner>
<Language name="R" sourceFile="test.R" entryPoint="foo"/>
<Ports>
<Output id="out_1" name="out1" type="DataTable">
<Description>...</Description>
</Output>
<Output id="out_2" name="out2" type="DataTable">
<Description>...</Description>
</Output>
</Ports>
</Module>

这会产生成功运行的模块:

Module in Azure

输出的可视化效果如下所示: Correct visualization of output 1 Empty visualization of output 2

虽然输出日志看起来不错:

[ModuleOutput] [1] "out1:"
[ModuleOutput]
[ModuleOutput] mpg cyl disp hp drat wt qsec vs am gear carb
[ModuleOutput]
[ModuleOutput] 1: 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
[ModuleOutput]
[ModuleOutput] 2: 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
[ModuleOutput]
[ModuleOutput] 3: 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
[ModuleOutput]
[ModuleOutput] 4: 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
[ModuleOutput]
[ModuleOutput] 5: 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
[ModuleOutput]
[ModuleOutput] 6: 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
[ModuleOutput]
[ModuleOutput] [1] "out2:"
[ModuleOutput]
[ModuleOutput] speed dist
[ModuleOutput]
[ModuleOutput] 1: 4 2
[ModuleOutput]
[ModuleOutput] 2: 4 10
[ModuleOutput]
[ModuleOutput] 3: 7 4
[ModuleOutput]
[ModuleOutput] 4: 7 22
[ModuleOutput]
[ModuleOutput] 5: 8 16
[ModuleOutput]
[ModuleOutput] 6: 9 10

我认为我正确地遵循了文档中的说明。以前有人遇到过这个问题吗?有已知的解决方案吗?

任何帮助将不胜感激!

最佳答案

R 输出桥需要一个数据帧,请尝试使用此数据而不是 data.table

out1 <- data.frame(mtcars)
out2 <- data.frame(cars)

关于r - 自定义模块的多个输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46422216/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com