title: How extraction decision rules of random forest in python?
body: <p>I am extracting decision rules from random forest, and I have read reference link :</p>
  
  <p><a href="https://stackoverflow.com/questions/50600290/how-extraction-decision-rules-of-random-forest-in-python/51004787#51004787">how extraction decision rules of random forest in python</a></p>
  
  <p>this code output is :</p>
  
  <pre><code>TREE: 0
  0 NODE: if feature[33] &lt; 2.5 then next=1 else next=4
  1 NODE: if feature[38] &lt; 0.5 then next=2 else next=3
  2 LEAF: return class=2
  3 LEAF: return class=9
  4 NODE: if feature[50] &lt; 8.5 then next=5 else next=6
  5 LEAF: return class=4
  6 LEAF: return class=0
  ...
  </code></pre>
  
  <p>but it is not a ideal output. It is not rules, just print trees.</p>
  
  <p>ideal output is :</p>
  
  <pre><code>IF weight&gt;80 AND weight&lt;150 AND height&lt;180 THEN figure=fat
  </code></pre>
  
  <p>I don't know how to generate ideal output. Looking forward to your help!</p>