1
$\begingroup$

I'm very new to computer coding and data science in general. I'm trying to open Weka and use it on a practice csv data set called weather.arff. The manual I have says to type this into command line:

java weka.classifiers.j48.J48 -t weather.arff

When I open the command line it goes to C:\User\Admin When I type in the above on command line it gives me message

Error: Could not find or load main class weka.classifiers.j48.J48

Might someone give me some advice on how to proceed to make the command line work. Thank you

$\endgroup$
2
  • 1
    $\begingroup$ You'll need to include weka.jar into your classpath for java. You can do this via the -cp command line argument for java: java -cp path/to/weka.jar weka.classifiers.j48.J48 -t weather.arff $\endgroup$ Commented Oct 25, 2019 at 22:15
  • $\begingroup$ If you're starting with Weka, you might want to explore it first with the graphical user interface: cs.waikato.ac.nz/~ml/weka/gui_explorer.html. Don't get me wrong, the command line interface is very useful! It's just that the GUI makes things much easier at first. You'll find lots of tutorials online about it. $\endgroup$
    – Erwan
    Commented Oct 25, 2019 at 22:33

1 Answer 1

1
$\begingroup$

I think your manual is for an older version of Weka. I have version 3.9.3. In some version the Weka developers have perhaps changed some internal structures and class names.

In a terminal window with a command line prompt, go to the directory where you have Weka installed, that is where the weka.jar file is located. There should be a data/ subdirectory.

cd c:\.....

There, run this command.

java -cp weka.jar weka.classifiers.trees.J48 -t data/weather.nominal.arff (Your data file name could be different)

Then I get this output:

=== Classifier model (full training set) ===

J48 pruned tree
------------------

outlook = sunny
|   humidity = high: no (3.0)
|   humidity = normal: yes (2.0)
outlook = overcast: yes (4.0)
outlook = rainy
|   windy = TRUE: no (2.0)
|   windy = FALSE: yes (3.0)

Number of Leaves  :     5

Size of the tree :  8


Time taken to build model: 0.33 seconds

Time taken to test model on training data: 0 seconds

=== Error on training data ===

Correctly Classified Instances          14              100      %
Incorrectly Classified Instances         0                0      %
Kappa statistic                          1     
Mean absolute error                      0     
Root mean squared error                  0     
Relative absolute error                  0      %
Root relative squared error              0      %
Total Number of Instances               14     


=== Detailed Accuracy By Class ===

                 TP Rate  FP Rate  Precision  Recall   F-Measure  MCC      ROC Area  PRC Area  Class
                 1.000    0.000    1.000      1.000    1.000      1.000    1.000     1.000     yes
                 1.000    0.000    1.000      1.000    1.000      1.000    1.000     1.000     no
Weighted Avg.    1.000    0.000    1.000      1.000    1.000      1.000    1.000     1.000     


=== Confusion Matrix ===

 a b   <-- classified as
 9 0 | a = yes
 0 5 | b = no

Time taken to perform cross-validation: 0.02 seconds


=== Stratified cross-validation ===

Correctly Classified Instances           7               50      %
Incorrectly Classified Instances         7               50      %
Kappa statistic                         -0.0426
Mean absolute error                      0.4167
Root mean squared error                  0.5984
Relative absolute error                 87.5    %
Root relative squared error            121.2987 %
Total Number of Instances               14     


=== Detailed Accuracy By Class ===

                 TP Rate  FP Rate  Precision  Recall   F-Measure  MCC      ROC Area  PRC Area  Class
                 0.556    0.600    0.625      0.556    0.588      -0.043   0.633     0.758     yes
                 0.400    0.444    0.333      0.400    0.364      -0.043   0.633     0.457     no
Weighted Avg.    0.500    0.544    0.521      0.500    0.508      -0.043   0.633     0.650     


=== Confusion Matrix ===

 a b   <-- classified as
 5 4 | a = yes
 3 2 | b = no
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.