我通过C#使用weka API。我已经使用ikvm将weka jar文件转换为C#DLL。然后我在我的参考文献中添加了转换后的DLL(wekacsharp.dll)。
我还在我的参考资料中添加了ikvm.gnu.classpath.dll,IKVM.OpenJDK.Core.dll,IKVM.OpenJDK.Util.dll,IKVM.OpenJDK.Text.dll,IKVM.OpenJDK.Core。
我正在尝试使用j48算法,但我收到错误。附上代码错误的屏幕截图。请检查并建议修复它。
J48 J48_tree = new J48(); //Creating J48 tree instance
DataSource data_source = new DataSource("iris.arff");
Instances data = data_source.getDataSet();
if (data.classIndex() == -1)
data.setClassIndex(data.numAttributes() - 1);
J48_tree.buildClassifier(data); // Builds the classifier
javax.swing.JFrame j_frame = new javax.swing.JFrame("J48 Tree");
//final javax.swing.JFrame j_frame = new javax.swing.JFrame("J48 Tree");
j_frame.setSize(1200,700);
j_frame.getContentPane().setLayout(new BorderLayout());
TreeVisualizer tree_visualizer = new TreeVisualizer(null, J48_tree.graph(), new PlaceNode2());
j_frame.getContentPane().add(tree_visualizer, BorderLayout.CENTER);
j_frame.addWindowListener(new java.awt.event.WindowAdapter() {public void windowClosing(java.awt.event.WindowEvent e) {j_frame.dispose(); }});
j_frame.setVisible(true);
tree_visualizer.fitToScreen();