Boolean attributes in Weka
Asked Answered
M

3

5

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?

Minify answered 17/9, 2013 at 17:25 Comment(0)
H
7

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.

Hydrocele answered 17/9, 2013 at 17:32 Comment(0)
T
2

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
Thebaine answered 7/7, 2015 at 12:22 Comment(0)
B
1

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.

Boesch answered 18/9, 2013 at 8:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.