Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

"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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top