2012-08-15 152 views
2

我想为Weka添加自定义分类器。这个分类器是在jar文件中。我已将它放入Weka文件夹并运行此命令java -classpath "D:/weka/ancl.jar;D:/weka_bin/weka.jar" weka.gui.GUIChooser Weka正常运行,但无法在分类器列表中找到我的分类器。如何将分类器添加到weka?

我也试过这种分类来GenericObjectEditor.props文件,但是当我运行秧鸡用的条命令上面我得到这个异常,当我打浏览器按钮

$ 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中的自动类发现工作?或者为什么它不actally :( 任何帮助appricieted

回答

0

我跟着这些指示,一切都很好:http://weka.wikispaces.com/Writing+your+own+Classifier+(post+3.5.2

快速浏览一下到底:

下面是一个例子呼吁秧鸡.classifiers.trees.Id3和生成的类weka.classifiers.WekaWrapper(它包装以伪分类的实际生成的代码):

java weka.classifiers.CheckSource \ 
    -W "weka.classifiers.trees.Id3" \ 
    -S weka.classifiers.WekaWrapper \ 
    -t data.arff \ 
    -c last 
0

虽然创建JAR纳入Java_cup,META_INF我们ka文件夹在一起,然后上面的错误将消失。

+0

你可以添加更多的细节?你如何一起创造它们? – rubo77 2015-02-08 23:22:32