Reputation: 4647
Is it possible to implement boolean attributes in WEKA?
I want to implement a market basket analysis and for this I need a table such
Product_A Prod_B
Yes No
No Yes
Yes Yes
and so on.
For No
, or false
, I can use ?
, that stands for a null value in WEKA:
Product_A Prod_B
Yes ?
? Yes
Yes Yes
But now I get freq. itemsets and rules like:
Product_A=Yes, Prod_B=Yes
But I only want to have
Product_A, Prod_B.
Do you know what I mean?
I found a guide about creating ARFF-Files but there aren't any boolean-datatypes.. But it would be useful to have such datatypes, or am I thinking wrong?
Upvotes: 5
Views: 6995
Reputation: 24049
Use f
and t
as nominal values. This is used in the supermarket.arff
example file and is compatible to the Java API.
I created such a "boolean" attribute with this Java code:
FastVector tempBooleanValues = new FastVector();
tempBooleanValues.addElement("f");
tempBooleanValues.addElement("t");
tempAttributes.addElement(new Attribute("attribute_1", tempBooleanValues));
In the arff file, it looks like this:
@attribute attribute_1 {f,t}
...
transaction_1,f
transaction_2,t
Upvotes: 2
Reputation: 77454
See the Weka supermarket.arff
file for an example.
If you want to use the sparse format, it gets a bit more tricky IIRC; because missing values are by default replaced with their mode - which would be Yes
then. But I believe the latest (not the book version) of Weka has improvements there.
Upvotes: 1
Reputation: 363567
Just use a numeric attributes with 0 and 1 for false and true. ML algorithms generally don't care about booleans, and will treat them as numbers anyway.
Upvotes: 7