2014-11-12 8 views
6

'dan kaldırılmıştır. Arrf uzatılmış çıktı dosyasını Java'daki çok boyutlu bir diziden almaya çalışıyorum. Ve weka kütüphanesi ithal ettim, ancak bir hatam var; The type FastVector<E> is deprecated.FastVector <E> türü

FastVector yerine ne kullanabilirim ve aşağıdaki kodu nasıl yeniden yazabilirim?

import weka.core.FastVector; //Error: The type FastVector<E> is deprecated. 


    int [][] myArray = new int[45194][12541]; 

    for (int i = 0; i < myArray.length; i++) { 
     for (int j = 0; j < myArray[0].length; j++) { 
      System.out.print(myArray[i][j]+" "); 
     } 
     System.out.println(""); 
    } 

    int numAtts = myArray[0].length; 
    FastVector atts = new FastVector(numAtts); 
    for (int att = 0; att < numAtts; att++) { 
     atts.addElement(new Attribute("Attribute" + att, att)); 
    } 

    int numInstances = myArray.length; 
    Instances dataset = new Instances("Dataset", atts, numInstances); 
    for (int inst = 0; inst < numInstances; inst++) { 
     dataset.add(new Instance(1.0, myArray[inst])); //Error: Cannot instantiate the type Instance 
    } 

    BufferedWriter writer = new BufferedWriter(new FileWriter("test.arff")); 
    writer.write(dataset.toString()); 
    writer.flush(); 
    writer.close(); 

cevap

13

Weka, şimdi çoğu yerde yazılan ArrayLists'i kullanır. Bunun için ArrayList<Attribute>'u kullanabilirsiniz:

ArrayList<Attribute> atts = new ArrayList<Attribute>(); 
    for (int att = 0; att < numAtts; att++) { 
     atts.add(new Attribute("Attribute" + att, att)); 
    } 
+2

Evet, bunu görüyorum, ancak yukarıdaki kodda ArrayList'i nasıl kullanabilirim? – EngineerEngin

+0

Yanıtımı bir kod snippet'iyle düzenledim. Atts değişkeninizin türünü değiştirmek kadar basit olmalı. – Chris

+0

Teşekkürler, işe yarıyor. FastVector hatası gitti. – EngineerEngin