2016-07-19 19 views
2

Ich habe this Tutorial zur Verwendung von WEKA gefolgt und ich habe einen Punkt erreicht, wo mein Code nicht ausgeführt wird. Ich merke, dass ich eine andere Version von Weka 3.8 verwende als 3.6, wie im Tutorial gezeigt, aber ich dachte, dass ich die notwendigen Änderungen vorgenommen habe. Ich bekomme eine Fehlermeldung in der Zeile linearRegression.buildClassifier(dataset); und ich weiß nicht warum.Weka lineare Regression lädt nicht

Fehlermeldung:

Jul 19, 2016 10:47:21 AM com.github.fommil.netlib.BLAS <clinit> 
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemBLAS 
Jul 19, 2016 10:47:21 AM com.github.fommil.netlib.BLAS <clinit> 
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeRefBLAS 
Jul 19, 2016 10:47:21 AM com.github.fommil.netlib.LAPACK <clinit> 
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemLAPACK 
Jul 19, 2016 10:47:21 AM com.github.fommil.netlib.LAPACK <clinit> 
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeRefLAPACK 

Code:

// Define each attribute (or column), and give it a numerical column 
     // number 
     // Likely, a better design wouldn't require the column number, but 
     // would instead get it from the index in the container 
     Attribute a1 = new Attribute("houseSize", 0); 
     Attribute a2 = new Attribute("lotSize", 1); 
     Attribute a3 = new Attribute("bedrooms", 2); 
     Attribute a4 = new Attribute("granite", 3); 
     Attribute a5 = new Attribute("bathroom", 4); 
     Attribute a6 = new Attribute("sellingPrice", 5); 

     // Each element must be added to a FastVector, a custom 
     // container used in this version of Weka. 
     // Later versions of Weka corrected this mistake by only 
     // using an ArrayList 
     ArrayList<Attribute> attrs = new ArrayList<>(); 
     attrs.add(a1); 
     attrs.add(a2); 
     attrs.add(a3); 
     attrs.add(a4); 
     attrs.add(a5); 
     attrs.add(a6); 
     // Each data instance needs to create an Instance class 
     // The constructor requires the number of columns that 
     // will be defined. In this case, this is a good design, 
     // since you can pass in empty values where they exist. 
     Instance i1 = new DenseInstance(6); 
     i1.setValue(a1, 3529); 
     i1.setValue(a2, 9191); 
     i1.setValue(a3, 6); 
     i1.setValue(a4, 0); 
     i1.setValue(a5, 0); 
     i1.setValue(a6, 205000); 

     Instance i2 = new DenseInstance(6); 
     i1.setValue(a1, 3247); 
     i1.setValue(a2, 10061); 
     i1.setValue(a3, 5); 
     i1.setValue(a4, 1); 
     i1.setValue(a5, 1); 
     i1.setValue(a6, 224900); 

     Instance i3 = new DenseInstance(6); 
     i1.setValue(a1, 4032); 
     i1.setValue(a2, 10150); 
     i1.setValue(a3, 5); 
     i1.setValue(a4, 0); 
     i1.setValue(a5, 1); 
     i1.setValue(a6, 197900); 

     Instance i4 = new DenseInstance(6); 
     i1.setValue(a1, 2397); 
     i1.setValue(a2, 14156); 
     i1.setValue(a3, 4); 
     i1.setValue(a4, 1); 
     i1.setValue(a5, 0); 
     i1.setValue(a6, 189900); 

     Instance i5 = new DenseInstance(6); 
     i1.setValue(a1, 2200); 
     i1.setValue(a2, 9600); 
     i1.setValue(a3, 4); 
     i1.setValue(a4, 0); 
     i1.setValue(a5, 1); 
     i1.setValue(a6, 195000); 

     Instance i6 = new DenseInstance(6); 
     i1.setValue(a1, 3536); 
     i1.setValue(a2, 19994); 
     i1.setValue(a3, 6); 
     i1.setValue(a4, 1); 
     i1.setValue(a5, 1); 
     i1.setValue(a6, 325000); 

     Instance i7 = new DenseInstance(6); 
     i1.setValue(a1, 2983); 
     i1.setValue(a2, 9365); 
     i1.setValue(a3, 5); 
     i1.setValue(a4, 0); 
     i1.setValue(a5, 1); 
     i1.setValue(a6, 230000); 

     // Each Instance has to be added to a larger container, the 
     // Instances class. In the constructor for this class, you 
     // must give it a name, pass along the Attributes that 
     // are used in the data set, and the number of 
     // Instance objects to be added. Again, probably not ideal design 
     // to require the number of objects to be added in the constructor, 
     // especially since you can specify 0 here, and then add Instance 
     // objects, and it will return the correct value later (so in 
     // other words, you should just pass in '0' here) 
     Instances dataset = new Instances("housePrices", attrs, 7); 
     dataset.add(i1); 
     dataset.add(i2); 
     dataset.add(i3); 
     dataset.add(i4); 
     dataset.add(i5); 
     dataset.add(i6); 
     dataset.add(i7); 

     // In the Instances class, we need to set the column that is 
     // the output (aka the dependent variable). You should remember 
     // that some data mining methods are used to predict an output 
     // variable, and regression is one of them. 
     dataset.setClassIndex(dataset.numAttributes() - 1); 

     // Create the LinearRegression model, which is the data mining 
     // model we're using in this example 
     linearRegression = new LinearRegression(); 
     try { 
      // This method does the "magic", and will compute the regression 
      // model. It takes the entire dataset we've defined to this point 
      // When this method completes, all our "data mining" will be 
      // complete 
      // and it is up to you to get information from the results 
      linearRegression.buildClassifier(dataset); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 

    } 

Antwort

1

Das ist kein Fehler, sondern eine Warnung. Weka kann einige Linear Algebra Libraries (LAPACK, BLAS) während des Startvorgangs Ihrer kleinen Java App nicht finden. Für die lineare Regressionsaufgabe, eine Kurve an 7 Datenpunkte anzupassen, werden sie ohnehin nicht benötigt.

(Lesen Sie diese als Referenz https://github.com/fommil/netlib-java)

Um die Nachricht loszuwerden, können Sie die STDERR-Ausgabe des Programms auf/dev/null umleiten.

den Paketmanager, Ich habe gerade die Weka Paket netlibNativeLinux (oder versuchen netlibNativeWindows oder netlibOSX, was auch immer), um den Build-Pfad seine Gläser enthalten, und bekam diese Warnung:

Jul 20, 2016 10:20:32 AM com.github.fommil.jni.JniLoader liberalLoad 
INFO: successfully loaded /tmp/jniloader5044252696376965086netlib-native_system-linux-x86_64.so 
Jul 20, 2016 10:20:32 AM com.github.fommil.jni.JniLoader load 
INFO: already loaded netlib-native_system-linux-x86_64.so 

Ich habe auch die Ausgabe 219328.35717359098 - genau wie im Tutorial gesagt. Haben Sie vergessen, die letzten Zeilen des Codes aus dem Tutorial zu schließen, vor allem

System.out.println(myHouseValue);

?

+0

Ich habe diese Pakete installiert und jetzt bekomme ich die Info-Nachricht, die Sie erhalten, aber es wird immer noch nicht gedruckt. Und ja, ich habe eine Druckanweisung. Das Programm stoppt direkt nachdem es diese Nachricht anzeigt, wenn ich eine Printline vor und nach 'linearRegression.buildClassifier (Dataset) setze;' Die erste wird drucken, aber die zweite wird nicht anzeigen, dass etwas an dieser Zeile abläuft. – user1762507

+0

Mein Code ist hier https://gist.github.com/knbknb/c7f75d8eaa5b50a7b6786ca5f0fedbfb, es druckt eine einzelne Nummer. Arbeitet für mich auf weka3.8 auf Linux, versuchte sowohl java7 (oracle jvm) als auch java8 openjdk. – knb

+0

Nun, gestern würde sowohl dein Code auf git hub als auch meins nicht funktionieren, heute arbeiten beide, ich habe wirklich keine Ahnung was das Problem war – user1762507

Verwandte Themen