在Azure ML studio中将字符串功能转换为数字时出错

时间:2018-01-04 01:26:50

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

QuotedPremium列是一个字符串功能,所以我需要将其转换为数值才能使用算法。

enter image description here

因此,我正在使用Edit Metadata模块,我在其中指定要转换的数据类型为Floating Point

运行后 - 我收到错误:

Could not convert type System.String to type System.Double, inner exception message: Input string was not in a correct format.

enter image description here

我在这里缺少什么?

1 个答案:

答案 0 :(得分:1)

如注释中所述,必须将将数字作为文本处理的列更改为数字类型数据,并且该字段不应包含任何空值。现在回答如何使用ML Studio替换数据中的NULL并将其转换为数字类型的问题。

用NULL代替数据

为此使用Execute R Script模块,并在其中添加此代码。

dataset1 <- maml.mapInputPort(1); # class: data.frame
dataset1[dataset1 == "NULL"] = 0; # Wherever cell's value is "NULL", replace it with 0
maml.mapOutputPort("dataset1"); # return the modified data.frame

相同图片: enter image description here

转换为数字数据

正如您在答案中添加的那样,可以使用Edit Metadata模块来完成此操作。