本文整理汇总了Python中Classifier.Classifier.r方法的典型用法代码示例。如果您正苦于以下问题:Python Classifier.r方法的具体用法?Python Classifier.r怎么用?Python Classifier.r使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Classifier.Classifier
的用法示例。
在下文中一共展示了Classifier.r方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply_ga
# 需要导入模块: from Classifier import Classifier [as 别名]
# 或者: from Classifier.Classifier import r [as 别名]
def apply_ga(aset: list, t: int, pop: list):
sumNum = 0
sumTgaN = 0
for CL in aset:
sumTgaN += CL.tga * CL.num
sumNum += CL.num
if (t - sumTgaN) / sumNum > cons.thetaGA:
for CL in aset:
CL.tga = t
parent1 = select_offspring(aset)
parent2 = select_offspring(aset)
child1 = Classifier(parent1)
child2 = Classifier(parent2)
child1.num += 1
child2.num += 1
child1.exp += 1
child2.exp += 1
apply_ga_mutation(child1)
apply_ga_mutation(child2)
if random() < cons.x:
apply_crossover(child1, child2)
child1.r = (parent1.r + parent2.r) / 2
child2.r = (parent1.r + parent2.r) / 2
child1.q = (parent1.q + parent2.q) / 2
child2.q = (parent1.q + parent2.q) / 2
child1.q /= 2
child2.q /= 2
delete_classifier(aset, pop)
if child1.condition != [cons.symbol] * cons.lenCondition:
add_ga_classifier(aset, pop, child1)
if child2.condition != [cons.symbol] * cons.lenCondition:
add_ga_classifier(aset, pop, child2)
示例2: cover_triple
# 需要导入模块: from Classifier import Classifier [as 别名]
# 或者: from Classifier.Classifier import r [as 别名]
def cover_triple(percept_: list, action: int, percept: list, t: int) -> Classifier:
child = Classifier()
for i in range(len(percept)):
if percept_[i] != percept[i]:
child.condition[i] = percept_[i]
child.effect[i] = percept[i]
child.action = action
child.exp = 0
child.r = 0
child.aav = 0
child.alp = t
child.tga = t
child.t = t
child.q = 0.5
child.num = 1
return child