Weka says 'training and test set are not compatible' when both are the same file - weka

I'm getting a very odd error from the weka machine learning toolkit:
java weka.classifiers.meta.AdaBoostM1 -t train.arff -d tmp.model -c 22 //generates the model
java weka.classifiers.meta.AdaBoostM1 -l tmp.model -T train.arff -p 22 //have the model predict values in the set it was trained on.
This produces the message:
java.lang.Exception: training and test set are not compatible
at weka.classifiers.Evaluation.evaluateModel(Evaluation.java:1035)
at weka.classifiers.Classifier.runClassifier(Classifier.java:312)
at weka.classifiers.meta.AdaBoostM1.main(AdaBoostM1.java:779)
But of course, the input files are the same... Any suggestions?

Sometimes Weka is complaining when the class variable does not consist of the same number of classes, e.g. when you training data consists of the classes {a,b,c} and the testing data (loaded later) only has {a,c}. In that case Weka just throws that nice exception :)
Maybe you find a solution in the Weka source code or by loading your data sets with the Weka Explorer. The latter one tells you how the data set is looking like when it is loaded...

Related

weka say that my data set train and test set are not compatible

why weka say my train and test file is not compatible
I'm trying to test my model with new dataset in weka. I have done the same preprocessing step as i have done for building my model. I have all the attributes(train vs test dataset) in same order, same attribute names and data types. But still i'm not able to resolve the issue. Both of the files train and test seems to be similar but the weka explorer is giving me error saying Train and test set are not compatible. How to resolve this error?

Weka libsvm is not in classpath after system format

While using weka SVM ,the error is receiving "libsvm is not in classpath'.
I set the classpath through environmental variables, But the error still remains.I was using the weka svm for one year for data classification, but I haven't gone through this kind of problem. This problem surfaced when I have installed weka 3.6.12 after formatting my system. I am using window 7 32-bit PC. The error "jdbc.idbDriver is not in path" is also exists.
Open SimpleCLI in your weka GUI and execute following commands.
java weka.core.SystemInfo
Please look for following values
java.class.path: ./weka.jar;
...
weka.version: 3.6.13
As you can see, I do not have libsvm.jar in my classpath too.
I have to include using one of the ways explained in http://weka.wikispaces.com/LibSVM.
Below passage is taken from (http://weka.wikispaces.com/LibSVM Troubleshooting)
Troubleshooting
libsvm classes not in CLASSPATH!◦Check whether the libsvm.jar is really in your CLASSPATH. Execute the following command in the SimpleCLI:
java weka.core.SystemInfo
The property java.class.path must list the libsvm.jar. If it is listed, check whether the path is correct.
If you're on Windows and you find %CLASSPATH% there, see next bullet point to fix this.
On Windows, if you added the libsvm.jar to your CLASSPATH environment variable, it can still happen that Weka pops up the error message that the libsvm classes are not in your CLASSPATH. This can happen on Windows 2000 and XP and the %CLASSPATH% does not get expanded to its actual value in starting up Weka. You can inspect your current CLASSPATH with which Weka got started up with the SimpleCLI (see previous bullet point). If %CLASSPATH% is listed there, your system has the same problem. This Wekalist post explains how to explicitly add the mysql.jar to RunWeka.ini (works the same for libsvm.jar).
Note: backslashes have to be escaped, not only once, but twice (they get interpreted by Java twice!). In other words, instead of one you have to use four: C:\some\where then turns into C:\\some\\where.
Write a startscript that sets up everything for you.
The file could be called weka.bat und should look like this (untested- adapt as necessary):
WEKA_HOME=c:\weka
set WEKA_JAR=%WEKA_HOME%\weka.jar
set PATH=$WEKA_HOME;$PATH
set CP="%WEKA_JAR%;%WEKA_HOME%\lib\libsvm.jar"
set DIR=c:\weka\data
cd "%DIR%"
set WEKA_HOME=%DIR%
rem start small GUI Chooser
java -cp $CP weka.gui.GUIChooser 2 >>c:\weka\weka.log
This assumes that you installed weka to a dir called c:\weka,
that the subdirectories \data and \lib exist, and that you have copied libsvm.jar into the \lib subdirectory.

WEKA Incremental Learning?

The idea of incremental learning that i understand, is that after Training, i save my model and when i have new data, instead of training the old data with new one, i just load the model i have saved and train again using the new data and the new trained model would build on top of the old one.
I have searched for this in WEKA and i found that this can be done using "Incremental Algorithms". I know that Hoefdding-Tree is an incremental version of the J48 algorithm but i am not sure how do the incremental learning.
If anybody could explain if this is possible in WEKA and how it could be done.
In order to do incremental learning in WEKA, you have to choose classifiers that implement an UpdatableClassifer Interface. There are 10 classifiers that can do this. Note that this can only be done using either coding or command line.
You have to first build your model from training data, then save the model. After that you use the same model and train more.
Using HoefddingTree algorithm, it would be something like this:
java weka.classifiers.trees.HoeffdingTree -L 2 -S 0 -E 1.0E-7 -H 0.1 -M 0.01 -G 200.0 -N 0.0 -t Training.arff -no-cv -d ht.model
java weka.classifiers.trees.HoeffdingTree -t Training.arff -T Testing.arff -l ht.model -d ht.updated.model
of-course there is no need to specify the training parameter again when updating the model because these settings are already saved in the model.
For more information:
http://weka.8497.n7.nabble.com/WEKA-Incremental-Learning-Training-td35691.html
https://weka.wikispaces.com/Classification-Train/test%20set#Classification-Building a Classifier-Incremental

Weka - Measuring testing time

I'm using Weka 3.6.8 to carry out some machine learning and I'm want to find the 'time taken to test model on training/testing data'. When I test a predictive model on evaluation data, this parameter seems to be missing. Has this feature been removed from Weka or is it just a setting I'm missing? All I seem to be able to find is the time taken to build the actual predictive model. (I've also checked the Weka Manual but can't find anything)
Thanks in advance
That feature was added to 3.7.7, you need to upgrade. You should be able to get this data by running the test on the command line with the -T parameter.

WEKA: Classifying an ARFF data with a given SMO model

I'm new with weka and this is my problem:
I've a unlabeled arff data and a given SMO model; I need classify this data with that model.
I searched examples, but all of them use a testing set to build classifier and I've not testing sets.
I need get classification with java or weka command line.
I tryed (under linux) command like:
java weka.classifiers.functions.SMO -l /path/of/mymodel/SMOModel.model -T /path/pf/myunlabeledarff/unlabeled.arff
but I get several errors :S
Can someone help me?
Thanks a lot
Documentation showing that the -l flag works is here: http://weka.wikispaces.com/Primer. That documentation also indicates that your syntax is correct, and that what you are trying to do is possible.
You say that the data is unlabeled: this can cause errors if the arff file you are using to predict does not match the format of the arff file which was used to create the model. Make sure that the arff header has the class attribute declared in it, and that every instance (row) in the file has a class value in it (even if the value is a ? to indicate unknown). Otherwise the formats won't match, and the classifier won't work.
Please post your error messages if this does not solve the problem.