Пример #1
0
 def __AppendTree(self):
     num_rows = self.df.shape[0]
     
     bootstraps = np.random.randint(0,num_rows, num_rows); # get random rows with replacement
     
     
     df_boot = self.df.iloc[bootstraps,:] # actually get the rows
     
     currTree = DecisionTree()
     
     CompleteDataSet = self.df
     if self.CompleteDataSet is not None:
         CompleteDataSet = self.CompleteDataSet
         
     currTree.BuildFromDataFrame(df_boot, num_rows, 2, None, self.__HandleUnknowns, CompleteDataSet)
     
     self.trees.append(currTree)
Пример #2
0
    def __AddNewTree(self):
        df = self.df
        currTree = DecisionTree()
        currTree.BuildFromDataFrame(df, 1, 2, self.D, self.HandleUnknowns)

        predictions = self.__GetPredictions(df, currTree)
        error = self.__CalculateTreeError(df, predictions)

        #        print(error)

        alpha = self.__CalculateAlpha(error)
        self.alphas.append(alpha)

        #       print(self.D)
        self.__UpdateD(df, predictions, alpha)

        #      print(self.D)

        self.trees.append(currTree)