0

I'm quite new in Weka.

I was wondering, is it possible for Weka to classify 2 different set of database which consists of different attributes in Weka?

Example:

Dataset A : @attributes {UserID, Tags, Descriptions} @data a,#user, writing books

Dataset B : @attributes {UserID, Longitude, Latitude, Dates} @data xyz ,7895231, 453221.1, 28.10.2012

Is it possible to merge Dataset A and B with different attribute into 1 dataset in Weka ? I was told that I can manually merge it in the excel before Weka classify it but I was wandering how does Weka read the data? Is it row by row? Is it logical to put in these form (excel) and put value 0?

Dataset AB : UserID, Tags, Descriptions, UserID, Longitude,
Latitude, Dates

         a,  #user, writing books, 0, 0,0
         xyz, 0, 0 , 7895231, 453221.1, 28.10.2012
JaneDoe
  • 1
  • 2
  • Possible duplicate of [Adding an instance to Instances in weka](https://stackoverflow.com/questions/10923947/adding-an-instance-to-instances-in-weka) – Abu Shoeb Dec 02 '18 at 08:08

1 Answers1

0

Yes. This is covered in this posting: https://list.waikato.ac.nz/pipermail/wekalist/2009-April/043232.html This also covers the situation in which you want to append two files (add instances).

This is done in the Weka Command Line Interface (CLI). One trick to this is that there seems to be a line length limit, so move your files to the default directory (which seems to be Program Files/Weka-3-8), so you don't have a problem with long paths.

Suppose we have the file "merge A.arff" consisting of

@relation 'merge A'

@attribute UserID numeric
@attribute A1 {Joe,Bill,Larry}
@attribute A2 numeric
@attribute Aclass {pos,neg}

@data
1,Joe,17,pos
3,Joe,42,neg
5,Bill,8,neg
7,Larry,4,neg

and the file "merge B.arff" consisting of

@relation 'merge B'

@attribute BUserID numeric
@attribute Blong numeric
@attribute Blat numeric

@data
1,-180,42
3,-182,45
5,-179,36
7,-184,38

then if you open the CLI and type the following after the > prompt

java weka.core.Instances merge "merge A.arff"  "merge B.arff"

the following will be dumped to the console:

@relation 'merge A_merge B'

@attribute UserID numeric
@attribute A1 {Joe,Bill,Larry}
@attribute A2 numeric
@attribute Aclass {pos,neg}
@attribute BUserID numeric
@attribute Blong numeric
@attribute Blat numeric

@data
1,Joe,17,pos,1,-180,42
3,Joe,42,neg,3,-182,45
5,Bill,8,neg,5,-179,36
7,Larry,4,neg,7,-184,38

For some reason, I'm having trouble piping this directly to another file, e.g.

 java weka.core.Instances merge "merge A.arff"  "merge B.arff" > "output.arff"

Either it's not creating the file, or I can't find where it's creating it. But one problem at a time!

zbicyclist
  • 691
  • 5
  • 10
  • can you please try to answer https://stackoverflow.com/questions/69923824/appending-two-files-in-weka – Encipher Nov 11 '21 at 15:44