我在我的數據上實現了Aprioiri算法。數據近700條記錄,近81個屬性。我想爲這些數據生成關聯規則。 這是我的程序代碼:weka.apriori中的java堆空間錯誤
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);
}
}
但十五分鐘後運行它提供了以下錯誤:
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)
的數據是在.arff格式,並且每個屬性具有1或0 。只有最後一個屬性代表最終的類。以下是來自數據的5個示例:
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
您能否找出問題所在?