Get errors when show all packages

36 views
Skip to first unread message

Truong-Son NGUYEN

unread,
Mar 28, 2016, 7:49:16 AM3/28/16
to python-weka-wrapper
Hi,

I have installed some packages and can run some classifiers with php-weka-wrapper such as libSVM. However, I get some errors when try to show all installed packages in weka. Could anyone help me. ( I attached the code and the errors below)

Thank you very much.

Son Nguyen.

---
import weka.core.jvm as jvm
import weka.core.packages as packages
jvm.start(packages=True)

items = packages.all_packages()
for item in items:
print item.name, item.url

jvm.stop()
---


I get the error like below:
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: Lorg/pentaho/packageManagement/Package;
Caused by: java.lang.ClassNotFoundException: org.pentaho.packageManagement.Package
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Traceback (most recent call last):
  File "/Users/sonnguyen/Bitbucket/conll2016-jaist/implicit-sdp/weka-test/test2.py", line 6, in <module>
    items = packages.all_packages()
  File "//anaconda/lib/python2.7/site-packages/weka/core/packages.py", line 241, in all_packages
    result.append(Package(pkge))
  File "//anaconda/lib/python2.7/site-packages/weka/core/packages.py", line 34, in __init__
    self.enforce_type(jobject, "org.pentaho.packageManagement.Package")
  File "//anaconda/lib/python2.7/site-packages/weka/core/classes.py", line 572, in enforce_type
    if not cls.check_type(jobject, intf_or_class, jni_intf_or_class):
  File "//anaconda/lib/python2.7/site-packages/weka/core/classes.py", line 556, in check_type
    return javabridge.is_instance_of(jobject, jni_intf_or_class)
  File "//anaconda/lib/python2.7/site-packages/javabridge/jutil.py", line 806, in is_instance_of
    raise JavaException(jexception)
javabridge.jutil.JavaException: Lorg/pentaho/packageManagement/Package;
Failed to get class Lorg/pentaho/packageManagement/Package;

Truong-Son NGUYEN

unread,
Mar 28, 2016, 10:39:28 AM3/28/16
to python-weka-wrapper

I get another error when doing attribute selection using the file attribute_selection_test. I am okay with other functions for feature selection such as use_filter, use_classifier. However, it causes some errors with function use_low_level.  Can I anyone help me ?

Thank you very much.

Best regards.

Son Nguyen.

def use_low_level(data):
"""
Uses the attribute selection API directly.
:param data: the dataset to use
:type data: Instances
"""
print("\n3. Low-level")
attsel = AttributeSelection()
aseval = ASEvaluation(classname="weka.attributeSelection.CfsSubsetEval")
assearch = ASSearch(classname="weka.attributeSelection.GreedyStepwise", options=["-B"])
attsel.jwrapper().setEvaluator(aseval.jobject)
attsel.jwrapper().setSearch(assearch.jobject)
attsel.select_attributes(data)
indices = attsel.selected_attributes
print("selected attribute indices (starting with 0):\n" + str(indices.tolist()))

However I get these errors:

3. Low-level

Traceback (most recent call last):
  File "/Users/sonnguyen/Bitbucket/conll2016-jaist/implicit-sdp/weka-test/AttributeSelectionTest.py", line 109, in <module>
    main(sys.argv)
  File "/Users/sonnguyen/Bitbucket/conll2016-jaist/implicit-sdp/weka-test/AttributeSelectionTest.py", line 104, in main
    use_low_level(data)
  File "/Users/sonnguyen/Bitbucket/conll2016-jaist/implicit-sdp/weka-test/AttributeSelectionTest.py", line 77, in use_low_level
    attsel.jwrapper().setEvaluator(aseval.jobject)
TypeError: 'JWrapper' object is not callable

Sebastián Vanrell

unread,
Mar 28, 2016, 11:00:33 AM3/28/16
to python-we...@googlegroups.com
I think you should not call .jwrapper() or .jobject unless you know what you are doing.

Have you tried with given examples?
check the link: http://pythonhosted.org/python-weka-wrapper/examples.html#attribute-selection


Sebastián

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.
To post to this group, send email to python-we...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-weka-wrapper/79fdedea-c4f7-48c3-8c92-247a5df4c5e0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Peter Reutemann

unread,
Mar 29, 2016, 4:22:11 PM3/29/16
to python-weka-wrapper
> I have installed some packages and can run some classifiers with
> php-weka-wrapper such as libSVM. However, I get some errors when try to show
> all installed packages in weka. Could anyone help me. ( I attached the code
> and the errors below)

[...]
The Weka package manager is currently undergoing some changes. Will
commit a fix hopefully next week when I have a proper internet
connection again.

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

Peter Reutemann

unread,
Mar 29, 2016, 4:31:05 PM3/29/16
to python-weka-wrapper
> I get another error when doing attribute selection using the file
> attribute_selection_test. I am okay with other functions for feature
> selection such as use_filter, use_classifier. However, it causes some errors
> with function use_low_level. Can I anyone help me ?
>
> Thank you very much.
>
> Best regards.
>
> Son Nguyen.
>
> def use_low_level(data):
> """
> Uses the attribute selection API directly.
> :param data: the dataset to use
> :type data: Instances
> """
> print("\n3. Low-level")
> attsel = AttributeSelection()
> aseval = ASEvaluation(classname="weka.attributeSelection.CfsSubsetEval")
> assearch = ASSearch(classname="weka.attributeSelection.GreedyStepwise",
> options=["-B"])
> attsel.jwrapper().setEvaluator(aseval.jobject)
> attsel.jwrapper().setSearch(assearch.jobject)

Don't use "jwrapper()" but "jwrapper" instead:

attsel.jwrapper.setEvaluator(aseval.jobject)
attsel.jwrapper.setSearch(assearch.jobject)


> attsel.select_attributes(data)
> indices = attsel.selected_attributes
> print("selected attribute indices (starting with 0):\n" +
> str(indices.tolist()))

[...]

Peter Reutemann

unread,
Mar 31, 2016, 4:06:39 PM3/31/16
to python-weka-wrapper

Peter Reutemann

unread,
Mar 31, 2016, 4:26:08 PM3/31/16
to python-weka-wrapper

Truong-Son NGUYEN

unread,
Apr 1, 2016, 8:10:58 AM4/1/16
to python-weka-wrapper, frac...@waikato.ac.nz

Thank you very much for your help.

Best regards,
Reply all
Reply to author
Forward
0 new messages