本文介绍了将 NA 值转换为 ?加载时自动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法自动将 NA 值转换为 ?在加载 .csv 文件时在 weka 中?或者我们是否必须使用其他脚本/程序来替换它们?或加载到weka之前的空白区域.

Is there a way to automatically convert NA values to ? in weka while loading .csv files?Or do we have to use some other script/program to either replace them with ? or a blank space before loading into weka.

欢迎任何帮助或建议.谢谢

Any help or suggestions are welcome. Thanks

推荐答案

不幸的是,我不相信 Weka 有办法进行这种转换.这是因为 Weka 的原生格式是 .arff 文件.在 .arff 文件中,缺失值用?"表示. 加载 .csv 文件时,它期望缺失值也用?"表示.

Unfortunately I do not believe Weka has a way to do this conversion. This is the case because Weka's native format is .arff files. In .arff files, missing values are denoted with a "?". When a .csv file is loaded, it expects missing values to also be denoted by "?".

根据您使用 Weka 的方法,我建议:

Depending on your method of using Weka I suggest:

  1. 对于 Weka GUI,在简单的文本编辑器中使用查找和替换"将NA"更改为?"在将 .csv 加载到 Weka 之前.

  1. For the Weka GUI, use "find and replace" in a simple text editor to change "NA" to "?" before loading the .csv into Weka.

对于 Weka Java API,编写一个方法来预处理您的.csv"文件,然后再将它交给 Weka .csv 加载器.

For the Weka Java API, write a method to preprocess your ".csv" file before handing it over to the Weka .csv loader.

这篇关于将 NA 值转换为 ?加载时自动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 22:23