【问题标题】:Weka J-48 decision Tree not completingWeka J-48 决策树未完成
【发布时间】:2014-12-29 21:55:36
【问题描述】:

我正在使用多属性数据集进行分类。我在 java 上使用 WEKA API。数据集既有分类变量也有数值变量。当我在 weka-GUI 上运行数据集时,我得到了更好的结果,在 26 大小的树中有 16 片叶子。但是当我使用 java 代码做同样的事情时,我只能在 5 大小的树中得到 3 片叶子。这是我的java代码

public static Evaluation classify(Classifier model,
        Instances trainingSet, Instances testingSet) throws Exception {

    //return the classification model after training with train set and test with test set

    Evaluation evaluation = new Evaluation(trainingSet);

    model.buildClassifier(trainingSet);
    evaluation.evaluateModel(model, testingSet);
    //System.out.println(model);
    return evaluation;
}

    Classifier models = new J48(); // a decision tree
    models.setOptions(optionsj);
    FastVector predictions = new FastVector();
    // For each training-testing split pair, train and test the classifier
    for (int i = 0; i < trainingSplits.length; i++) {
        Evaluation validation = classify(models, trainingSplits[i], testingSplits[i]);

        predictions.appendElements(validation.predictions());
        System.out.println(validation.toSummaryString("\nResults\n======\n", false));
    }

    System.out.println(models.toString());

如何确保 j-48 获取数据集中的所有属性?我做错了什么?

【问题讨论】:

  • 你确定J48的参数和Weka-GUI中的参数一致吗?
  • optionsj 的值是多少?您是否将 Weka GUI 中的值(“分类/选择”按钮旁边)复制并粘贴到此变量中?

标签: java weka decision-tree


【解决方案1】:

您必须设置一个参数,称为修剪或非修剪。修剪意味着树只显示决策树中最重要的叶子。非修剪意味着它显示了决策树中的每个变量。在这里,您只是使用修剪过的树。如果你想要完整的树集

pruned = "False" 

【讨论】:

    猜你喜欢
    • 2015-02-06
    • 2014-11-23
    • 2021-04-30
    • 2014-11-25
    • 2021-05-16
    • 2020-08-25
    • 2017-01-25
    • 2021-12-10
    • 2016-09-02
    相关资源
    最近更新 更多