1

I'm trying to understand how the following .arff file can be expressed in Weka when loading data from database instead of the file. An .arff file has the following form:

@relation sample
@attribute expression string
@attribute tone {postive,negative}

@data
'this is a happy message', positive
'this is an unhappy message', negative

In the case of loading data from a database, consisting of one table with two fields - expression and tone - , how can I let weka know that the field tone gets only two possible values, positive or negative ?

Both of the fields are Strings. I want to apply NominalToString filter on expression to convert it to String and the apply StringToWord filter. However because of the tone attribute it can't be done... Any solutions?

2 Answers2

0

"However because of the tone attribute it can't be done..." -- I don't see why. You could process only the 'expression' field. You could apply NominalToString selectively on whatever attributes you want. Check the setAttributeIndexes function out.

user1669710
  • 224
  • 1
  • 11
0

I asked same question before. You may see detailed answer and necessary code in that question.

short answer : you merge correct arff header from external file with data from database.

Community
  • 1
  • 1
Atilla Ozgur
  • 14,339
  • 3
  • 49
  • 69