Failed to get class weka/classifiers/EvaluationWrapper

506 views
Skip to first unread message

José David Lopes

unread,
Aug 27, 2014, 12:35:16 PM8/27/14
to python-we...@googlegroups.com
Hi,

I'm trying to use this wrapper, but I'm quite stuck right now and I didn't find anything that could solve my problem so far.
I'm running this piece of code:

        loader = Loader()
        data = loader.load_file(os.path.join(self.path,arffFile))
        data.set_class_index(data.num_attributes()-1)
        stringsToWordVectors = Filter(classname="weka.filters.unsupervised.attribute.StringToWordVector", options = ["-R","first-last","-W","1000","-prune-rate","-1.0",\
                                                                                                                     "-N","0","-stemmer","weka.core.stemmers.NullStemmer",\
                                                                                                                     "-M","1","-tokenizer",\
                                                                                                                     "weka.core.tokenizers.WordTokenizer "\
                                                                                                                     "-delimiters \"\\r\\n\\n.,;:\\\'\\\"()?!\""])
        stringsToWordVectors.set_inputformat(data)
        filtered_data = stringsToWordVectors.filter(data)
        classifier = Classifier(classname="weka.classifiers.trees.J48", options=["-C", "0.3"])
        evaluation = Evaluation(filtered_data)
        evaluation.crossvalidate_model(classifier, filtered_data, 10, Random(42))
        print evaluation.to_summary()


, but the execution stops when I initialize the Evaluation class. It says Failed to get class weka/classifiers/EvaluationWrapper. Does anybody have an idea why this is happening? I'm trying to run it with Windows 7 64-bit.

Thanks,
José David Lopes


Peter Reutemann

unread,
Aug 27, 2014, 5:49:50 PM8/27/14
to python-we...@googlegroups.com
> , but the execution stops when I initialize the Evaluation class. It says
> Failed to get class weka/classifiers/EvaluationWrapper. Does anybody have an
> idea why this is happening? I'm trying to run it with Windows 7 64-bit.

How do you start up the JVM? Below is the output that the attached
script generates. Note the "python-weka-wrapper.jar", which contains
the EvaluationWrapper class:

DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Classpath=['/usr/local/lib/python2.7/dist-packages/javabridge/jars/rhino-1.7R4.jar',
'/usr/local/lib/python2.7/dist-packages/javabridge/jars/runnablequeue.jar',
'/home/fracpete/development/projects/python-weka-wrapper/python/weka/lib/python-weka-wrapper.jar',
'/home/fracpete/development/projects/python-weka-wrapper/python/weka/lib/weka.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:javabridge.jutil:Creating JVM object
DEBUG:javabridge.jutil:Signalling caller

Cheers, Peter
--
Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
http://www.cms.waikato.ac.nz/~fracpete/ Ph. +64 (7) 858-5174
blah.py

José David Lopes

unread,
Aug 28, 2014, 3:12:57 AM8/28/14
to python-we...@googlegroups.com, frac...@waikato.ac.nz
Thanks for such quick answer!!

If I launch the jvm by doing jvm.start(), I get this:
 
DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Classpath=['C:\\Python27\\lib\\site-packages\\javabridge-1.0.7-py2.7-win-amd64.egg\\javabridge\\jars\\rhino-1.7R4.jar', 'C:\\Python27\\lib\\site-packages\\javabridge-1.0.7-py2.7-win-amd64.egg\\javabridge\\jars\\runnablequeue.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:javabridge.jutil:Creating JVM object
DEBUG:javabridge.jutil:Signalling caller
Failed to get class weka/core/converters/ArffLoader

If I start it this way jvm.start(packages=True,system_cp=True), I get this:

DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Adding Weka packages
DEBUG:weka.core.jvm:package_dir=C:\Users\jdlopes\wekafiles\packages
DEBUG:weka.core.jvm:  directory=C:\Users\jdlopes\wekafiles\packages\HMM
DEBUG:weka.core.jvm:Adding system classpath
DEBUG:weka.core.jvm:Classpath=['C:\\Python27\\lib\\site-packages\\javabridge-1.0.7-py2.7-win-amd64.egg\\javabridge\\jars\\rhino-1.7R4.jar', 'C:\\Python27\\lib\\site-packages\\javabridge-1.0.7-py2.7-win-amd64.egg\\javabridge\\jars\\runnablequeue.jar', 'C:\\Users\\jdlopes\\wekafiles\\packages\\HMM\\HMM.jar', 'C:\\Users\\jdlopes\\wekafiles\\packages\\HMM\\lib\\JFlex.jar', 'C:\\Users\\jdlopes\\wekafiles\\packages\\HMM\\lib\\junit.jar', 'C:\\Users\\jdlopes\\wekafiles\\packages\\HMM\\lib\\packageManager.jar', 'C:\\Users\\jdlopes\\wekafiles\\packages\\HMM\\lib\\weka.jar', '.', 'C:\\LIBsvm\\libsvm-3.18\\java\\libsvm.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:javabridge.jutil:Creating JVM object
DEBUG:javabridge.jutil:Signalling caller
Failed to get class weka/classifiers/EvaluationWrapper

It seems that it is loading the wrong weka.jar (the one from the HMM package) and it is not loading the wrapper jar at all. Am I missing some step that involves adding the wrapper folder to some path?

Thanks,
José


 

Peter Reutemann

unread,
Aug 28, 2014, 11:04:59 PM8/28/14
to python-we...@googlegroups.com
I'm a bit baffled why the weka.jar and python-weka-wrapper.jar are
missing from your classpath. I only tested python-weka-wrapper on
Linux and Mac. Are the jars located below a folder like this?
C:\\Python27\\lib\\site-packages\\python-weka-wrapper-XXX

How did you install python-weka-wrapper? pip install python-weka-wrapper?

I just pushed out a minor bugfix (release 0.1.10). Now you can add
custom classpath elements. For instance:
jvm.start(class_path=['C:\\some\\where\\python-weka-wrapper.jar',
'C:\\some\\where\weka.jar'])

BTW The HMM plugin should never have included the junit,
packageManager and weka jars in the Weka package, as this will
interfere with the outer Weka instance that uses the plugin....

José David Lopes

unread,
Sep 17, 2014, 11:13:18 AM9/17/14
to python-we...@googlegroups.com, frac...@waikato.ac.nz
Thanks Peter! This has been working great for me!
Reply all
Reply to author
Forward
0 new messages