Ameer Abdullah
Ameer Abdullah

Reputation: 61

java heap space error in weka.apriori

I am implementing Aprioiri algorithm on my data. The data is having almost 700 records with almost 81 attributes. I want to generate association rules for that data. This is the code for my program:

public class Aprioritest {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) throws Exception {
String dataset = "C:/Users/pc-4/Desktop/CasebaseWithDiseasenamesCSV_1.arff";
DataSource source = new DataSource(dataset);
Instances newData = source.getDataSet();

NumericToNominal filter = new NumericToNominal();
    filter.setInputFormat(newData);
    newData = Filter.useFilter(newData, filter);

      for(int i=0; i<5; i=i+1)
    {
        System.out.println("Nominal? "+newData .attribute(i).isNominal());
    }

    Apriori model = new Apriori();

model.buildAssociations(newData);
System.out.println(model);
}

}

But after running for fifteen minutes it gives the following error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3181)
    at java.util.ArrayList.grow(ArrayList.java:261)
    at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:235)
    at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:227)
    at java.util.ArrayList.add(ArrayList.java:458)
    at weka.associations.AprioriItemSet.mergeAllItemSets(AprioriItemSet.java:587)
    at weka.associations.Apriori.findLargeItemSets(Apriori.java:1677)
    at weka.associations.Apriori.buildAssociations(Apriori.java:518)
    at aprioritest.Aprioritest.main(Aprioritest.java:43)
C:\Users\pc-4\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53:         
Java returned: 1
BUILD FAILED (total time: 15 minutes 27 seconds)

The data is in .arff format and each attribute has either 1 or 0. Only last attribute represents the resulting class. Following are the 5 examples from data:

0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,A 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,A 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,A 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,A 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,A

can you please find out the problem?

Upvotes: 2

Views: 290

Answers (1)

Has QUIT--Anony-Mousse
Has QUIT--Anony-Mousse

Reputation: 77454

Instead of 0, use undefined to indicate absence.

Also, you will need to increase the memory limit, and should rather consider more efficient algorithms such as FPGrowth, and more memory efficient tools than Weka.

Upvotes: 1

Related Questions