跳到内容

包装器

此文件是 TPOT 库的一部分。

当前版本的 TPOT 由 Cedars-Sinai 的以下人员开发:— Pedro Henrique Ribeiro (https://github.com/perib, https://www.linkedin.com/in/pedro-ribeiro/) — Anil Saini (anil.saini@cshs.org) — Jose Hernandez (jgh9094@gmail.com) — Jay Moran (jay.moran@cshs.org) — Nicholas Matsumoto (nicholas.matsumoto@cshs.org) — Hyunjun Choi (hyunjun.choi@cshs.org) — Gabriel Ketron (gabriel.ketron@cshs.org) — Miguel E. Hernandez (miguel.e.hernandez@cshs.org) — Jason Moore (moorejh28@gmail.com)

TPOT 的原始版本主要由宾夕法尼亚大学的以下人员开发:— Randal S. Olson (rso@randalolson.com) — Weixuan Fu (weixuanf@upenn.edu) — Daniel Angell (dpa34@drexel.edu) — Jason Moore (moorejh28@gmail.com) — 以及许多慷慨的开源贡献者

TPOT 是免费软件:您可以根据自由软件基金会发布的 GNU 宽松通用公共许可证(Lesser General Public License)的条款重新分发和/或修改它,可以是许可证的第 3 版,也可以是(由您选择的)任何后续版本。

分发 TPOT 是希望它有用,但没有任何担保;甚至不包括对适销性或特定用途适用性的默示担保。更多详情请参阅 GNU 宽松通用公共许可证。

您应该已经收到了 TPOT 随附的 GNU 宽松通用公共许可证副本。如果没有,请参阅 https://gnu.ac.cn/licenses/

WrapperPipeline

基类:搜索空间

源代码位于 tpot/search_spaces/pipelines/wrapper.py
class WrapperPipeline(SearchSpace):
    def __init__(
            self, 
            method: type, 
            space: ConfigurationSpace,
            estimator_search_space: SearchSpace,
            hyperparameter_parser: callable = None, 
            wrapped_param_name: str = None
            ) -> None:

        """
        This search space is for wrapping a sklearn estimator with a method that takes another estimator and hyperparameters as arguments.
        For example, this can be used with sklearn.ensemble.BaggingClassifier or sklearn.ensemble.AdaBoostClassifier.

        """


        self.estimator_search_space = estimator_search_space
        self.method = method
        self.space = space
        self.hyperparameter_parser=hyperparameter_parser
        self.wrapped_param_name = wrapped_param_name

    def generate(self, rng=None):
        rng = np.random.default_rng(rng)
        return WrapperPipelineIndividual(method=self.method, space=self.space, estimator_search_space=self.estimator_search_space, hyperparameter_parser=self.hyperparameter_parser, wrapped_param_name=self.wrapped_param_name,  rng=rng)

__init__(method, space, estimator_search_space, hyperparameter_parser=None, wrapped_param_name=None)

此搜索空间用于将 sklearn 估计器包装在一个方法中,该方法接受另一个估计器和超参数作为参数。例如,这可以与 sklearn.ensemble.BaggingClassifier 或 sklearn.ensemble.AdaBoostClassifier 一起使用。

源代码位于 tpot/search_spaces/pipelines/wrapper.py
def __init__(
        self, 
        method: type, 
        space: ConfigurationSpace,
        estimator_search_space: SearchSpace,
        hyperparameter_parser: callable = None, 
        wrapped_param_name: str = None
        ) -> None:

    """
    This search space is for wrapping a sklearn estimator with a method that takes another estimator and hyperparameters as arguments.
    For example, this can be used with sklearn.ensemble.BaggingClassifier or sklearn.ensemble.AdaBoostClassifier.

    """


    self.estimator_search_space = estimator_search_space
    self.method = method
    self.space = space
    self.hyperparameter_parser=hyperparameter_parser
    self.wrapped_param_name = wrapped_param_name