Example #1
0
 def graph(self):
     text = "{"
     # self.assignIDs(-1)
     # text+="digraph J48Tree {\n"
     if self.m_isLeaf:
         text += '"' + Utils.backQuoteChars(
             self.m_localModel.dumpLabel(0, self.m_train)) + '"'
         # if self.m_train is not None and self.m_train.numInstances() > 0:
         #     text+="data =\n" + str(self.m_train) + "\n"
         #     text+=",\n"
         # text+="]\n"
     else:
         text += '"' + Utils.backQuoteChars(
             self.m_localModel.leftSide(self.m_train)) + '":'
         # if self.m_train is not None and self.m_train.numInstances() > 0:
         #     text+="data =\n" + str(self.m_train) + "\n"
         #     text+=",\n"
         # text+=']\n'
         text = self.graphTree(text)
     text += "}"
     return text
Example #2
0
 def graphTree(self, text: str):
     text += "{"
     for i in range(len(self.m_sons)):
         if i != 0:
             text += ","
         text += '"' + Utils.backQuoteChars(
             self.m_localModel.rightSide(i, self.m_train).strip()) + '":'
         if self.m_sons[i].m_isLeaf:
             text += '"' + Utils.backQuoteChars(
                 self.m_localModel.dumpLabel(i, self.m_train)) + '"'
             # if self.m_train is not None and self.m_train.numInstances() > 0:
             #     text+="data =\n" + str(self.m_sons[i].m_train) + "\n,\n"
             # text+="]\n"
         else:
             text += '{'
             text += '"' + Utils.backQuoteChars(
                 self.m_sons[i].m_localModel.leftSide(self.m_train)) + '":'
             # if self.m_train is not None and self.m_train.numInstances() > 0:
             #     text+="data =\n" + str(self.m_sons[i].m_train) + "\n,\n"
             # text+=']\n'
             text = self.m_sons[i].graphTree(text)
             text += "}"
     text += "}"
     return text