2

I want to add custom classifier to Weka. This classifier is in jar file. I've put it into the Weka folder and run this command java -classpath "D:/weka/ancl.jar;D:/weka_bin/weka.jar" weka.gui.GUIChooser Weka runs normally but I can't find my classifier on the classifiers list.

I've also tried to this classifier to GenericObjectEditor.props file, but when I run weka with the the commmand above I get this exception when I hit Explorer button

$ java -classpath "D:/weka/ancl.jar;D:/weka_bin/weka.jar"  weka.gui.GUIChooser
---Registering Weka Editors---
Checking class: weka.core.MathematicalExpression
java.lang.ExceptionInInitializerError
        java.lang.Class.forName0(Native Method)
        java.lang.Class.forName(Unknown Source)
        weka.core.ClassDiscovery.find(ClassDiscovery.java:416)
        weka.core.AllJavadoc.<clinit>(AllJavadoc.java:59)
        java.lang.Class.forName0(Native Method)
        java.lang.Class.forName(Unknown Source)
        weka.core.ClassDiscovery.find(ClassDiscovery.java:416)
        weka.gui.GenericPropertiesCreator.generateOutputProperties(GenericProper                                                                     tiesCreator.java:455)
        weka.gui.GenericPropertiesCreator.execute(GenericPropertiesCreator.java:                                                                     534)
        weka.core.converters.ConverterUtils.<clinit>(ConverterUtils.java:714)
        weka.gui.ConverterFileChooser.<clinit>(ConverterFileChooser.java:110)
        weka.gui.explorer.PreprocessPanel.<init>(PreprocessPanel.java:162)
        weka.gui.explorer.Explorer.<init>(Explorer.java:184)
        weka.gui.GUIChooser.showExplorer(GUIChooser.java:1074)
        weka.gui.GUIChooser$17.actionPerformed(GUIChooser.java:928)
        javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        java.awt.Component.processMouseEvent(Unknown Source)
        javax.swing.JComponent.processMouseEvent(Unknown Source)
        java.awt.Component.processEvent(Unknown Source)
        java.awt.Container.processEvent(Unknown Source)
        java.awt.Component.dispatchEventImpl(Unknown Source)
        java.awt.Container.dispatchEventImpl(Unknown Source)
        java.awt.Component.dispatchEvent(Unknown Source)
        java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        java.awt.Container.dispatchEventImpl(Unknown Source)
        java.awt.Window.dispatchEventImpl(Unknown Source)
        java.awt.Component.dispatchEvent(Unknown Source)
        java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        java.awt.EventQueue.access$000(Unknown Source)
        java.awt.EventQueue$3.run(Unknown Source)
        java.awt.EventQueue$3.run(Unknown Source)
        java.security.AccessController.doPrivileged(Native Method)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.awt.EventQueue$4.run(Unknown Source)
        java.awt.EventQueue$4.run(Unknown Source)
        java.security.AccessController.doPrivileged(Native Method)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.awt.EventQueue.dispatchEvent(Unknown Source)
        java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        java.awt.EventDispatchThread.run(Unknown Source)

        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at weka.core.ClassDiscovery.find(ClassDiscovery.java:416)
        at weka.core.AllJavadoc.<clinit>(AllJavadoc.java:59)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at weka.core.ClassDiscovery.find(ClassDiscovery.java:416)
        at weka.gui.GenericPropertiesCreator.generateOutputProperties(GenericPro                                                                     pertiesCreator.java:455)
        at weka.gui.GenericPropertiesCreator.execute(GenericPropertiesCreator.ja                                                                     va:534)
        at weka.core.converters.ConverterUtils.<clinit>(ConverterUtils.java:714)
        at weka.gui.ConverterFileChooser.<clinit>(ConverterFileChooser.java:110)
        at weka.gui.explorer.PreprocessPanel.<init>(PreprocessPanel.java:162)
        at weka.gui.explorer.Explorer.<init>(Explorer.java:184)
        at weka.gui.GUIChooser.showExplorer(GUIChooser.java:1074)
        at weka.gui.GUIChooser$17.actionPerformed(GUIChooser.java:928)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour                                                                     ce)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Uncompilable source code - package java_c                                                                     up.runtime does not exist
        at weka.core.MathematicalExpression.<clinit>(MathematicalExpression.java                                                                     :26)
        ... 51 more
Checking class: weka.core.MathematicalExpression
java.lang.NoClassDefFoundError: Could not initialize class weka.core.Mathematica                                                                     lExpression
        java.lang.Class.forName0(Native Method)
        java.lang.Class.forName(Unknown Source)
        weka.core.ClassDiscovery.find(ClassDiscovery.java:416)
        weka.gui.GenericPropertiesCreator.generateOutputProperties(GenericProper                                                                     tiesCreator.java:455)
        weka.gui.GenericPropertiesCreator.execute(GenericPropertiesCreator.java:                                                                     534)
        weka.core.converters.ConverterUtils.<clinit>(ConverterUtils.java:714)
        weka.gui.ConverterFileChooser.<clinit>(ConverterFileChooser.java:110)
        weka.gui.explorer.PreprocessPanel.<init>(PreprocessPanel.java:162)
        weka.gui.explorer.Explorer.<init>(Explorer.java:184)
        weka.gui.GUIChooser.showExplorer(GUIChooser.java:1074)
        weka.gui.GUIChooser$17.actionPerformed(GUIChooser.java:928)
        javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        java.awt.Component.processMouseEvent(Unknown Source)
        javax.swing.JComponent.processMouseEvent(Unknown Source)
        java.awt.Component.processEvent(Unknown Source)
        java.awt.Container.processEvent(Unknown Source)
        java.awt.Component.dispatchEventImpl(Unknown Source)
        java.awt.Container.dispatchEventImpl(Unknown Source)
        java.awt.Component.dispatchEvent(Unknown Source)
        java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        java.awt.Container.dispatchEventImpl(Unknown Source)
        java.awt.Window.dispatchEventImpl(Unknown Source)
        java.awt.Component.dispatchEvent(Unknown Source)
        java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        java.awt.EventQueue.access$000(Unknown Source)
        java.awt.EventQueue$3.run(Unknown Source)
        java.awt.EventQueue$3.run(Unknown Source)
        java.security.AccessController.doPrivileged(Native Method)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.awt.EventQueue$4.run(Unknown Source)
        java.awt.EventQueue$4.run(Unknown Source)
        java.security.AccessController.doPrivileged(Native Method)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.awt.EventQueue.dispatchEvent(Unknown Source)
        java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        java.awt.EventDispatchThread.run(Unknown Source)

        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at weka.core.ClassDiscovery.find(ClassDiscovery.java:416)
        at weka.gui.GenericPropertiesCreator.generateOutputProperties(GenericPro                                                                     pertiesCreator.java:455)
        at weka.gui.GenericPropertiesCreator.execute(GenericPropertiesCreator.ja                                                                     va:534)
        at weka.core.converters.ConverterUtils.<clinit>(ConverterUtils.java:714)
        at weka.gui.ConverterFileChooser.<clinit>(ConverterFileChooser.java:110)
        at weka.gui.explorer.PreprocessPanel.<init>(PreprocessPanel.java:162)
        at weka.gui.explorer.Explorer.<init>(Explorer.java:184)
        at weka.gui.GUIChooser.showExplorer(GUIChooser.java:1074)
        at weka.gui.GUIChooser$17.actionPerformed(GUIChooser.java:928)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour                                                                     ce)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Checking class: weka.filters.unsupervised.attribute.MathExpression
java.lang.ExceptionInInitializerError
        java.lang.Class.forName0(Native Method)
        java.lang.Class.forName(Unknown Source)
        weka.core.ClassDiscovery.find(ClassDiscovery.java:416)
        weka.gui.GenericPropertiesCreator.generateOutputProperties(GenericProper                                                                     tiesCreator.java:455)
        weka.gui.GenericPropertiesCreator.execute(GenericPropertiesCreator.java:                                                                     534)
        weka.core.converters.ConverterUtils.<clinit>(ConverterUtils.java:714)
        weka.gui.ConverterFileChooser.<clinit>(ConverterFileChooser.java:110)
        weka.gui.explorer.PreprocessPanel.<init>(PreprocessPanel.java:162)
        weka.gui.explorer.Explorer.<init>(Explorer.java:184)
        weka.gui.GUIChooser.showExplorer(GUIChooser.java:1074)
        weka.gui.GUIChooser$17.actionPerformed(GUIChooser.java:928)
        javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        java.awt.Component.processMouseEvent(Unknown Source)
        javax.swing.JComponent.processMouseEvent(Unknown Source)
        java.awt.Component.processEvent(Unknown Source)
        java.awt.Container.processEvent(Unknown Source)
        java.awt.Component.dispatchEventImpl(Unknown Source)
        java.awt.Container.dispatchEventImpl(Unknown Source)
        java.awt.Component.dispatchEvent(Unknown Source)
        java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        java.awt.Container.dispatchEventImpl(Unknown Source)
        java.awt.Window.dispatchEventImpl(Unknown Source)
        java.awt.Component.dispatchEvent(Unknown Source)
        java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        java.awt.EventQueue.access$000(Unknown Source)
        java.awt.EventQueue$3.run(Unknown Source)
        java.awt.EventQueue$3.run(Unknown Source)
        java.security.AccessController.doPrivileged(Native Method)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.awt.EventQueue$4.run(Unknown Source)
        java.awt.EventQueue$4.run(Unknown Source)
        java.security.AccessController.doPrivileged(Native Method)
        java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        java.awt.EventQueue.dispatchEvent(Unknown Source)
        java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        java.awt.EventDispatchThread.run(Unknown Source)

        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at weka.core.ClassDiscovery.find(ClassDiscovery.java:416)
        at weka.gui.GenericPropertiesCreator.generateOutputProperties(GenericPro                                                                     pertiesCreator.java:455)
        at weka.gui.GenericPropertiesCreator.execute(GenericPropertiesCreator.ja                                                                     va:534)
        at weka.core.converters.ConverterUtils.<clinit>(ConverterUtils.java:714)
        at weka.gui.ConverterFileChooser.<clinit>(ConverterFileChooser.java:110)
        at weka.gui.explorer.PreprocessPanel.<init>(PreprocessPanel.java:162)
        at weka.gui.explorer.Explorer.<init>(Explorer.java:184)
        at weka.gui.GUIChooser.showExplorer(GUIChooser.java:1074)
        at weka.gui.GUIChooser$17.actionPerformed(GUIChooser.java:928)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour                                                                     ce)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour                                                                     ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Uncompilable source code - package java_c                                                                     up.runtime does not exist
        at weka.filters.unsupervised.attribute.MathExpression.<clinit>(MathExpre                                                                     ssion.java:38)
        ... 47 more

Could anyone tell me how the automatic class discovery in Weka works? Or why it doesn't actally :( Any help appricieted

4

2 回答 2

0

我按照这些说明进行操作,一切都很好:

https://waikato.github.io/weka-wiki/writing_classifier/

快速浏览一下结尾:

这是对 weka.classifiers.trees.Id3 和生成的类 weka.classifiers.WekaWrapper 的示例调用(它将实际生成的代码包装在伪分类器中):

java weka.classifiers.CheckSource \
    -W "weka.classifiers.trees.Id3" \
    -S weka.classifiers.WekaWrapper \
    -t data.arff \
    -c last
于 2012-09-04T13:38:13.770 回答
0

在创建 jar 时将 Java_cup、Meta_Inf 和 weka 文件夹合并在一起,然后上述错误将消失。

于 2015-02-08T22:56:22.160 回答