Ejemplo n.º 1
0
    def get_estimator(self, idx):
        """Extract a single estimator tree from the forest.

        :param int idx: The index of the tree to extract.
        """
        check_is_fitted(self)
        if not self.enable_tree_details:
            raise ValueError(
                "enable_tree_details must be True prior to training")
        return GRFTreeSurvival.from_forest(self, idx=idx)
Ejemplo n.º 2
0
 def estimators_(self):
     try:
         check_is_fitted(self)
     except NotFittedError:
         raise AttributeError(
             f"{self.__class__.__name__} object has no attribute 'estimators_'"
         ) from None
     if not self.enable_tree_details:
         raise ValueError(
             "enable_tree_details must be True prior to training")
     return [
         GRFTreeSurvival.from_forest(self, idx=idx)
         for idx in range(self.n_estimators)
     ]
Ejemplo n.º 3
0
 def test_from_forest(self, lung_X, lung_y):
     forest = GRFForestSurvival()
     forest.fit(lung_X, lung_y)
     tree = GRFTreeSurvival.from_forest(forest=forest, idx=0)
     tree.predict(lung_X)