Incompatible Models

451 views
Skip to first unread message

Eva

unread,
Feb 25, 2015, 6:58:15 AM2/25/15
to python-we...@googlegroups.com
Hi there!

I'd like to load a trained classifier using this wrapper, but my main problem is that this trained classifier was created previously in java. 

trained_classifier = Classifier(jobject=serialization.read("/home/smo_from_java.model"))

Then, when I try to load it from python I get this exception: 
javabridge.jutil.JavaException: cannot assign instance of java.util.Vector to field weka.core.AttributeLocator.m_Locators of type java.util.ArrayList in instance of weka.core.RelationalLocator

From python, if I create and train a classifier and save it, when I load it in "Classify" tab of Weka GUI, it appears a popup with the message below:

"java.lang.ClassCastException: cannot assign instance of java.util.ArrayList to field weka.core.Instances.m_Attributes of type weka.core.FastVector in instance of weka.core.Instances"
  

It seems to be a compatibility problem but I'd like to know if there exists some kind of patch to solve that before creating a new trained classifier in python (it was hard to get my trained java classifier)

Thanks in advance!

Peter Reutemann

unread,
Feb 25, 2015, 1:06:11 PM2/25/15
to python-weka-wrapper

I presume, that the trained model was generated with Weka 3.7.11 or earlier? There were some API changes in Weka which unfortunately results in incompatible models. We had the same problem here.

In a nutshell, you will have to use an older (and probably buggier version) of python-weka-wrapper or rebuild the models. We did the latter.

Cheers, Peter

Eva

unread,
Feb 26, 2015, 3:17:39 AM2/26/15
to python-we...@googlegroups.com, frac...@waikato.ac.nz
Thanks Peter!
 
I generated my java model with weka 3.6.12 so you're completely right. I'll do the latter as you mentioned. Thank you again.

Peter Reutemann

unread,
Feb 26, 2015, 3:35:20 AM2/26/15
to python-weka-wrapper


> I generated my java model with weka 3.6.12 so you're completely right. I'll do the latter as you mentioned. Thank you again.

Yes, python-weka-wrapper only ever worked with the 3.7.x branch of Weka.

Cheers, Peter

Reply all
Reply to author
Forward
0 new messages