该文件是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)
- 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 宽通用公共许可证的条款重新分发和/或修改它,许可证的版本可以是第 3 版,或者(根据您的选择)任何以后的版本。
TPOT 的发布是希望它能有用,
但没有任何保证;甚至没有对
适销性或特定用途适用性的暗示保证。更多详情请参阅
GNU 较宽松通用公共许可证。
您应该已经收到了一份GNU较宽松通用公共许可证的副本,随TPOT一起提供。如果没有,请参见http://www.gnu.org/licenses/。
UnionPipeline
基类: SearchSpace
Source code in tpot2/search_spaces/pipelines/union.py
| class UnionPipeline(SearchSpace):
def __init__(self, search_spaces : List[SearchSpace] ) -> None:
"""
Takes in a list of search spaces. will produce a pipeline of Sequential length. Each step in the pipeline will correspond to the the search space provided in the same index.
"""
self.search_spaces = search_spaces
def generate(self, rng=None):
rng = np.random.default_rng(rng)
return UnionPipelineIndividual(self.search_spaces, rng=rng)
|
__init__(search_spaces)
接收一个搜索空间列表。将生成一个顺序长度的管道。管道中的每一步将对应于相同索引中提供的搜索空间。
Source code in tpot2/search_spaces/pipelines/union.py
| def __init__(self, search_spaces : List[SearchSpace] ) -> None:
"""
接受一个搜索空间列表。将生成一个顺序长度的管道。管道中的每一步将对应于提供的相同索引中的搜索空间。
"""
self.search_spaces = search_spaces
|
UnionPipelineIndividual
基类:SklearnIndividual
接收一个搜索空间列表。每个空间是一个SearchSpaces列表。
将生成一个FeatureUnion管道。管道中的每个步骤将对应于相同索引中提供的搜索空间。
生成的管道将是管道中步骤的FeatureUnion。
Source code in tpot2/search_spaces/pipelines/union.py
| class UnionPipelineIndividual(SklearnIndividual):
"""
Takes in a list of search spaces. each space is a list of SearchSpaces.
Will produce a FeatureUnion pipeline. Each step in the pipeline will correspond to the the search space provided in the same index.
The resulting pipeline will be a FeatureUnion of the steps in the pipeline.
"""
def __init__(self, search_spaces : List[SearchSpace], rng=None) -> None:
super().__init__()
self.search_spaces = search_spaces
self.pipeline = []
for space in self.search_spaces:
self.pipeline.append(space.generate(rng))
def mutate(self, rng=None):
rng = np.random.default_rng(rng)
step = rng.choice(self.pipeline)
return step.mutate(rng)
def crossover(self, other, rng=None):
#swap a random step in the pipeline with the corresponding step in the other pipeline
rng = np.random.default_rng(rng)
cx_funcs = [self._crossover_node, self._crossover_swap_node]
rng.shuffle(cx_funcs)
for cx_func in cx_funcs:
if cx_func(other, rng):
return True
return False
def _crossover_swap_node(self, other, rng):
rng = np.random.default_rng(rng)
idx = rng.integers(1,len(self.pipeline))
self.pipeline[idx], other.pipeline[idx] = other.pipeline[idx], self.pipeline[idx]
return True
def _crossover_node(self, other, rng):
rng = np.random.default_rng(rng)
crossover_success = False
for idx in range(len(self.pipeline)):
if rng.random() < 0.5:
if self.pipeline[idx].crossover(other.pipeline[idx], rng):
crossover_success = True
return crossover_success
def export_pipeline(self, **kwargs):
return sklearn.pipeline.make_union(*[step.export_pipeline(**kwargs) for step in self.pipeline])
def unique_id(self):
l = [step.unique_id() for step in self.pipeline]
l = ["FeatureUnion"] + l
return TupleIndex(tuple(l))
|