예제 #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 GRFTreeRegressor.from_forest(self, idx=idx)
예제 #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 [
         GRFTreeRegressor.from_forest(self, idx=idx)
         for idx in range(self.n_estimators)
     ]
예제 #3
0
 def test_from_forest(self, boston_X, boston_y):
     forest = GRFForestRegressor()
     forest.fit(boston_X, boston_y)
     tree = GRFTreeRegressor.from_forest(forest=forest, idx=0)
     tree.predict(boston_X)