我想向Weka添加自定义分类器。此分类器位于jar文件中。我已将它放入Weka文件夹并运行此命令java -classpath "D:/weka/ancl.jar;D:/weka_bin/weka.jar" weka.gui.GUIChooser
Weka正常运行但我在分类器列表中找不到我的分类器。
我也试过这个分类器到GenericObjectEditor.props文件,但是当我用上面的命令运行weka时,当我点击Explorer按钮时我得到了这个异常
$ 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
有人能告诉我Weka中的自动类发现是如何工作的吗?或者为什么它不合法:( 任何有用的帮助
答案 0 :(得分:0)
我遵循了这些说明,一切都很好:http://weka.wikispaces.com/Writing+your+own+Classifier+(post+3.5.2)
快速浏览一下:
这是对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
答案 1 :(得分:0)
创建jar时,将Java_cup,Meta_Inf和weka文件夹合并在一起,然后上面的错误将消失。