jeudi 29 mars 2018

Optimize Random Forest parameters in weka?

I am trying to optimize random forest parameters using weka, the java class is as the following:

package pkg10foldcrossvalidation;

import weka.core.*;
import weka.classifiers.meta.*;
import weka.classifiers.trees.RandomForest;
import java.io.*;
public class RF_Optimizer {



     public static void main(String[] args) throws Exception {
      // load data
      BufferedReader reader = new BufferedReader(new FileReader("C:\\Prediction Results on the testing set\\Dataset.arff"));
      Instances data = new Instances(reader);
      reader.close();
      data.setClassIndex(data.numAttributes() - 1);

      // setup classifier
      CVParameterSelection ps = new CVParameterSelection();
      ps.setClassifier(new RandomForest());
      ps.setNumFolds(10);  // using 10-fold CV
      ps.addCVParameter("C 0.1 0.5 5");

      // build and output best options
      ps.buildClassifier(data);
      System.out.println(Utils.joinOptions(ps.getBestClassifierOptions()));
   }

}

But I am facing difficulty of understanding which parameters should replace the "C" and how the range of each one could be determined? And is it workable to use .addCVParameter several times for several parameter at the same time?

I tried to search for some youtube or website tutorials that explain how to change random forest parameters in java but nothing found.

Thank you




Aucun commentaire:

Enregistrer un commentaire