在 Weka 中附加两个文件 [英] appending two files in Weka

查看:26
本文介绍了在 Weka 中附加两个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数据集.基本上,它们是两个 .arff 文件.

I have two datasets. Basically, they are two .arff file.

Fold1.arff 包含:

Fold1.arff contains:

@relation iris

@attribute sepallength numeric
@attribute sepalwidth numeric
@attribute petallength numeric
@attribute petalwidth numeric
@attribute class {Iris-setosa,Iris-versicolor,Iris-virginica}

@data
5.1,3.5,1.4,0.2,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5,3.5,1.3,0.3,Iris-setosa
7,3.2,4.7,1.4,Iris-versicolor
5,2,3.5,1,Iris-versicolor
5.9,3.2,4.8,1.8,Iris-versicolor
5.5,2.4,3.8,1.1,Iris-versicolor
5.5,2.6,4.4,1.2,Iris-versicolor
6.3,3.3,6,2.5,Iris-virginica
6.5,3.2,5.1,2,Iris-virginica
6.9,3.2,5.7,2.3,Iris-virginica
7.4,2.8,6.1,1.9,Iris-virginica
6.7,3.1,5.6,2.4,Iris-virginica

Fold2.arff 包含

Fold2.arff contains

@relation iris

@attribute sepallength numeric
@attribute sepalwidth numeric
@attribute petallength numeric
@attribute petalwidth numeric
@attribute class {Iris-setosa,Iris-versicolor,Iris-virginica}

@data
4.9,3,1.4,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
6.4,3.2,4.5,1.5,Iris-versicolor
5.9,3,4.2,1.5,Iris-versicolor
6.1,2.8,4,1.3,Iris-versicolor
5.5,2.4,3.7,1,Iris-versicolor
6.1,3,4.6,1.4,Iris-versicolor
5.8,2.7,5.1,1.9,Iris-virginica
6.4,2.7,5.3,1.9,Iris-virginica
5.6,2.8,4.9,2,Iris-virginica
7.9,3.8,6.4,2,Iris-virginica
6.9,3.1,5.1,2.3,Iris-virginica

现在我尝试使用以下命令附加它们:

Now I try to append them using the command:

java weka.core.Instances append d:\fold1.arff d:\fold2.arff > d:\result.arff

我从 Weka 简单 CLI 字段运行命令.

I run the command from the Weka simple CLI field.

我收到此错误:

Usage:
weka.core.Instances help
    Prints this help
weka.core.Instances <filename>
    Outputs dataset statistics
weka.core.Instances merge <filename1> <filename2>
    Merges the datasets (must have same number of rows).
    Generated dataset gets output on stdout.
weka.core.Instances append <filename1> <filename2>
    Appends the second dataset to the first (must have same number of attributes).
    Generated dataset gets output on stdout.
weka.core.Instances headers <filename1> <filename2>
    Compares the structure of the two datasets and outputs whether they
    differ or not.
weka.core.Instances randomize <seed> <filename>
    Randomizes the dataset and outputs it on stdout.

我的两个文件的行数与您从上面的示例中看到的相同.那为什么不能创建result.arff文件呢?

My two files have same number of rows as you can see from the above example. Then why the result.arff file could not create?

谢谢.

推荐答案

我看你的两个文件,属性是一样的,属性数也一样(一共5个)

I can see in your two files that the attributes are same and has same number of attributes (5 in total)

来自 官方文档 append 的当前语法是

From the official documentation the current syntax for append is

    weka.core.Instances append <filename1> <filename2>

这会将文件名 2 附加到文件名 1.无需指定输出文件.即所有更改都存储在 filename1 本身中

This appends filename2 to filename1. No need to specify the output file. That is all changes are stored in filename1 itself

注意用引号(单引号或双引号)传递文件名是理想的,尤其是在文件名有空格的情况下(例如,fold 1.arff 而不是 fold1.arff)

Note It’s ideal to pass file name in quotes (single or double quotes) especially in scenarios when your filename has blank space (eg., fold 1.arff instead of fold1.arff)

      java weka.core.Instances append "d:\fold1.arff" "d:\fold2.arff"

在少数语言中,blackslash 是一个转义序列,因此必须使用两次

In few languages, blackslash is an escape sequence and so has to be used twice

      java weka.core.Instances append "d:\\fold1.arff" "d:\\fold2.arff"

这篇关于在 Weka 中附加两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆