Level Order Tree Traversal of C4.5 (J48) Tree

[email protected]
Newsgroups gmane.comp.ai.weka
Message-ID <162486275267.9590.13520058803063825232@sys-mailman-prd.its.waikato.ac.nz>
Dear Weka developers,

I am trying to perform Level Order Tree Traversal of the J48 Tree
based on the following post, which describes Level Order Tree
Traversal of a non-binary tree:

https://www.geeksforgeeks.org/generic-tree-level-order-traversal/

I have added the following method to ClassifierTree.java:

private void dumpTreeLevelOrder(Instances root, StringBuffer text){

    if (root==null)
      return;

    Queue<Instances> q =new LinkedList<>();
    q.add(root);

    while(!q.isEmpty()){
      int n = q.size();
      while (n>0){
        Instances p = q.peek();
        q.remove();
        text.append(m_localModel.leftSide(p));
        text.append(m_localModel.rightSide(1, p)+" ");
        for (int i=0; i<m_sons.length; i++)
          q.add(m_sons[i].m_train);
        n--;
      }
      text.append("\n");
    }
  }

And I call the code from the toString() method with the following command:

dumpTreeLevelOrder(m_train, text);

I get an OutOfMemoryError Exception!

Could anyone please help on how the code should be appropriately changed?

Thank you in advance,

Spyros Halkidis
_______________________________________________
Wekalist mailing list -- [email protected]
Send posts to [email protected]
To unsubscribe send an email to [email protected]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.