en:Troubleshooting
From WekaDoc
Here are a few of things that are useful to know when you are having trouble installing or running Weka successfully on your machine.
NB these java commands refer to ones executed in a shell (bash, command prompt, etc.) and NOT to commands executed in the SimpleCLI.
| Table of contents |
Weka download problems
When you download Weka, make sure that the resulting file size is the same as on our webpage. Otherwise things won't work properly. Apparently some web browsers have trouble downloading Weka.
OutOfMemoryException
Most Java virtual machines only allocate a certain maximum amount of memory to run Java programs. Usually this is much less than the amount of RAM in your computer. However, you can extend the memory available for the virtual machine by setting appropriate options. With Sun's JDK, for example, you can go
java -Xmx100m ...
to set the maximum Java heap size to 100MB. For more information about these options, follow this (http://java.sun.com/docs/hotspot/VMOptions.html) link.
Windows
Since Windows is the only OS currently that provides an installer, one has to modify some files to increase the heap size.
Book version
You have to modify the JVM invocation in the RunWeka.bat batch file in your installation directory.
Developer version
- up to Weka 3.5.2
just like the book version. - Weka 3.5.3
You have to modify the link in the Windows Start menu, if you're starting the console-less Weka (only the link with console in its name executes theRunWeka.batbatch file) - Weka 3.5.4 and higher
Due to the new launching scheme, you no longer modify the batch file, but theRunWeka.inifile. In that particular file, you'll have to change the maxheap placeholder. Check out the documentation for your specific Weka version on WekaDoc (under CLASSPATH).
StackOverflowError
Try increasing the stack of your virtual machine. With Sun's JDK you can use this command to increase the stacksize:
java -Xss512k ...
to set the maximum Java stack size to 512KB. If still not sufficient, slowly increase it.
just-in-time (JIT) compiler
For maximum enjoyment, use a virtual machine that incorporates a just-in-time compiler. This can speed things up quite significantly. Note also that there can be large differences in execution time between different virtual machines.
CSV file conversion
Either load the CSV file in the Explorer or use the CVS converter on the commandline as follows:
java weka.core.converters.CSVLoader filename.csv > filename.arff
ARFF file doesn't load
One way to figure out why ARFF files are failing to load is to give them to the Instances class. At the command line type the following:
java weka.core.Instances filename.arff
where you substitute 'filename' for the actual name of your file. This should return an error if there is a problem reading the file, or show some statistics if the file is ok. The error message you get should give some indication of what is wrong.
Spaces in labels of ARFF files
A common problem people have with ARFF files is that labels can only have spaces if they are enclosed in single quotes, i.e. a label such as:
some value
should be written either 'some value' or some_value in the file.
CLASSPATH problems
Having problems getting Weka to run from a DOS/UNIX command prompt? Getting java.lang.NoClassDefFoundError exceptions? Most likely your CLASSPATH environment variable is not set correctly - it needs to point to the Weka.jar file that you downloaded with Weka (or the parent of the Weka directory if you have extracted the jar). Under DOS this can be achieved with:
set CLASSPATH=c:\weka-3-4\weka.jar;%CLASSPATH%
Under UNIX/Linux something like:
export CLASSPATH=/home/weka/weka.jar:$CLASSPATH
An easy way to get avoid setting the variable this is to specify the CLASSPATH when calling Java. For example, if the jar file is located at c:\weka-3-4\weka.jar you can use:
java -cp c:\weka-3-4\weka.jar weka.classifiers... etc.
See also the CLASSPATH article.
Instance ID
People often want to tag their instances with identifiers, so they can keep track of them and the predictions made on them.
Adding the ID
A new ID attribute is added real easy: one only needs to run the AddID filter over the dataset and it's done. Here's an example (at a DOS/Unix command prompt):
java weka.filters.unsupervised.attribute.AddID -i data_without_id.arff -o data_with_id.arff
(all on a single line)
Note: the AddID filter adds a numeric attribute, not a String attribute to the dataset. If you want to remove this ID attribute for the classifier in a FilteredClassifier environment again, use the Remove filter instead of the RemoveType filter (same package).
Removing the ID
If you run from the command line you can use the -p option to output predictions plus any other attributes you are interested in. So it is possible to have a string attribute in your data that acts as an identifier. A problem is that most classifiers don't like String attributes, but you can get around this by using the RemoveType (this removes String attributes by default).
Here's an example. Lets say you have a training file named train.arff, a testing file named test.arff, and they have an identifier String attribute as their 5th attribute. You can get the predictions from J48 along with the identifier strings by issuing the following command (at a DOS/Unix command prompt):
java weka.classifiers.meta.FilteredClassifier -F weka.filters.unsupervised.attribute.RemoveType -W weka.classifiers.trees.J48 -t train.arff -T test.arff -p 5
(all on a single line)
If you want, you can redirect the output to a file by adding " > output.txt" to the end of the line.
In the Explorer GUI you could try a similar trick of using the String attribute identifiers here as well. Choose the FilteredClassifier, with the RemoveType as the filter, and whatever classifier you prefer. When you visualize the results you will need click through each instance to see the identifier listed for each.
Visualization
Access to visualization from the ClassifierPanel, ClusterPanel and AttributeSelection panel is available from a popup menu. Click the right mouse button over an entry in the Result list to bring up the menu. You will be presented with options for viewing or saving the text output and --- depending on the scheme --- further options for visualizing errors, clusters, trees etc.
Memory consumption and Garbage collector
There is the ability to print how much memory is available in the Explorer and Experimenter and to run the garbage collector. Just right click over the Status area in the Explorer/Experimenter.
GUIChooser starts but not Experimenter or Explorer
The GUIChooser starts, but Explorer and Experimenter don't start and output an Exception like this in the terminal:
/usr/share/themes/Mist/gtk-2.0/gtkrc:48: Engine "mist" is unsupported, ignoring
---Registering Weka Editors---
java.lang.NullPointerException
at weka.gui.explorer.PreprocessPanel.addPropertyChangeListener(PreprocessPanel.java:519)
at javax.swing.plaf.synth.SynthPanelUI.installListeners(SynthPanelUI.java:49)
at javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:38)
at javax.swing.JComponent.setUI(JComponent.java:652)
at javax.swing.JPanel.setUI(JPanel.java:131)
...
This behavior happens only under Java 1.5 and Gnome/Linux, KDE doesn't produce this error. The reason for this is, that Weka tries to look more "native" and therefore sets a platform-specific Swing theme. Unfortunately, this doesn't seem to be working correctly in Java 1.5 together with Gnome. A workaround for this is to set the cross-platform Metal theme.
In order to use another theme one only has to create the following properties file in ones home directory:
LookAndFeel.props
With this content:
Theme=javax.swing.plaf.metal.MetalLookAndFeel
More information can be found in this Weka list post (https://list.scms.waikato.ac.nz/mailman/htdig/wekalist/2005-April/003906.html) or here.
KnowledgeFlow toolbars are empty
In the terminal, you will most likely see this output as well:
Failed to instantiate: weka.gui.beans.Loader
This behavior can happen under Gnome with Java 1.5, see GUIChooser starts but not Experimenter or Explorer for a solution. Encountered in this Weka list post (https://list.scms.waikato.ac.nz/mailman/htdig/wekalist/2006-June/007380.html).
Links
- Java VM options http://java.sun.com/docs/hotspot/VMOptions.html
