The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

"Modify Decision Tree Spliting Score"

cplaicplai Member Posts: 4 image Contributor I
edited June 2019 in Help
Hi all,

I am new in RapidMiner and I need help for my testing. I would like to use RapidMiner to construct a decision tree for me, but I would like to use new splitting criterion instead of Gain Ratio, Info Gain, Gini Index or the other which are provided by RapidMiner. May I know could I do that? Below is some code which generate standard decision tree with Gain Ratio.

/**
*
* @author CP Lai
*/
public class MIM_DT {

    //RapidMiner operators
    private Operator exampleSource;
    private Operator decisionTree;
    private Operator modelWriter;

    public MIM_DT(){

        try{
            // Tell the Java application where rapidminer located and start rapidminer
            System.setProperty("rapidminer.home", "C:\\Program Files\\Rapid-I\\RapidMiner");
            RapidMiner.init(false, false, false, true);

            // Initialize ExampleSource operator
            exampleSource = OperatorService.createOperator( "ExampleSource" );
            exampleSource.setParameter("attributes", "C:\\Documents and Settings\\student\\Desktop\\MIMDT\\clev_training.aml");

            decisionTree = OperatorService.createOperator("DecisionTree");
            decisionTree.setParameter("criterion", "gain_ratio");

            modelWriter = OperatorService.createOperator("ModelWriter");
            modelWriter.setParameter("model_file", "C:\\Documents and Settings\\student\\Desktop\\MIMDT\\clev_training3.mod");
            modelWriter.setParameter("output_type", "Binary");

            this.runMIM_DT();
        }

        catch(Exception e){
            e.printStackTrace();
        }
    }

    private void runMIM_DT(){
       
        try {
            IOContainer container = exampleSource.apply(new IOContainer());
            ExampleSet eSet = container.get(ExampleSet.class);

            container = decisionTree.apply(container);
            Model aModel = container.get(Model.class);
            System.out.println("Result???");
            System.out.println(aModel.toString());

            container = modelWriter.apply(container);
            Model outModel = container.get(Model.class);

        } catch (OperatorException ex) {
            Logger.getLogger(MIM_DT.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void main(String[] args){
        MIM_DT aTree = new MIM_DT();
    }

}

Your help will be fully appreciated by me. Thanks you

Chee Ping
Tagged:

Answers

  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 image Unicorn
    Hi,
    you might simply put the fully qualified class name into the criterion parameter. The class should be constructed automatically, but must implement the Criterion interface.

    Greetings,
      Sebastian
  • cplaicplai Member Posts: 4 image Contributor I
    Hi Sebastian,

    Do you means I need to create my custom splitting criterion? May I know how to create it? I am scratching my head of finding the solution of modify splitting condition.

    Anyway, thanks for your reply.

    Regards,

    Chee Ping
Sign In or Register to comment.