本文整理汇总了Python中tpot.TPOTClassifier._random_mutation_operator方法的典型用法代码示例。如果您正苦于以下问题:Python TPOTClassifier._random_mutation_operator方法的具体用法?Python TPOTClassifier._random_mutation_operator怎么用?Python TPOTClassifier._random_mutation_operator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tpot.TPOTClassifier
的用法示例。
在下文中一共展示了TPOTClassifier._random_mutation_operator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mut_operator_stats_update
# 需要导入模块: from tpot import TPOTClassifier [as 别名]
# 或者: from tpot.TPOTClassifier import _random_mutation_operator [as 别名]
def test_mut_operator_stats_update():
"""Asserts that self._random_mutation_operator updates stats as expected."""
tpot_obj = TPOTClassifier()
tpot_obj._fit_init()
ind = creator.Individual.from_string(
'KNeighborsClassifier('
'BernoulliNB(input_matrix, BernoulliNB__alpha=10.0, BernoulliNB__fit_prior=False),'
'KNeighborsClassifier__n_neighbors=10, '
'KNeighborsClassifier__p=1, '
'KNeighborsClassifier__weights=uniform'
')',
tpot_obj._pset
)
initialize_stats_dict(ind)
ind.statistics["crossover_count"] = random.randint(0, 10)
ind.statistics["mutation_count"] = random.randint(0, 10)
# set as evaluated pipelines in tpot_obj.evaluated_individuals_
tpot_obj.evaluated_individuals_[str(ind)] = tpot_obj._combine_individual_stats(2, 0.99, ind.statistics)
for _ in range(10):
offspring, = tpot_obj._random_mutation_operator(ind)
assert offspring.statistics['crossover_count'] == ind.statistics['crossover_count']
assert offspring.statistics['mutation_count'] == ind.statistics['mutation_count'] + 1
assert offspring.statistics['predecessor'] == (str(ind),)
ind = offspring