Weka WrapperSubsetEval仅将类属性作为选定要素返回

时间:2013-07-18 11:31:03

标签: machine-learning weka

我尝试使用WrapperSubsetEval在weka中进行特征选择。它似乎工作但只返回class属性作为选定的功能。请帮忙,谢谢!

weka.attributeSelection.AttributeSelection attsel = new weka.attributeSelection.AttributeSelection();

        WrapperSubsetEval eval = new WrapperSubsetEval();
        BestFirst search = new BestFirst();
        String[]  optionsSearch = null;
        String[]  optionsEval = null;
        String[] optionsBase = null;
        try {
            optionsSearch = weka.core.Utils.splitOptions("-D 1 -N 5");
            search.setOptions(optionsSearch);



            LibSVM base = new LibSVM();
            optionsBase = weka.core.Utils.splitOptions("-S 4");
            base.setOptions(optionsBase);

            optionsEval = weka.core.Utils.splitOptions("");
            eval.setOptions(optionsEval);
            eval.setClassifier(base);
            eval.setFolds(5);

            attsel.setEvaluator(eval);
            attsel.setSearch(search);
            dataTrain.setClassIndex(dataTrain.numAttributes() -1);
            attsel.SelectAttributes(dataTrain);
            idx.add( attsel.selectedAttributes() );
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

0 个答案:

没有答案