当前位置: 首页>>代码示例>>Python>>正文


Python Classifier.condition方法代码示例

本文整理汇总了Python中Classifier.Classifier.condition方法的典型用法代码示例。如果您正苦于以下问题:Python Classifier.condition方法的具体用法?Python Classifier.condition怎么用?Python Classifier.condition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Classifier.Classifier的用法示例。


在下文中一共展示了Classifier.condition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: expected_case

# 需要导入模块: from Classifier import Classifier [as 别名]
# 或者: from Classifier.Classifier import condition [as 别名]
def expected_case(cli: Classifier, percept: list) -> Classifier:
    """

    :rtype: Classifier
    """
    diff = get_differences(cli.mark, percept)
    if diff == [cons.symbol] * cons.lenCondition:
        cli.q += cons.beta * (1 - cli.q)
        return None
    else:
        spec = number_of_spec(cli.condition)
        spec_new = number_of_spec(diff)
        child = Classifier(cli)
        if spec == cons.uMax:
            remove_random_spec_att(child.condition)
            spec -= 1
            while spec + spec_new > cons.beta:
                if spec > 0 and random() < 0.5:
                    remove_random_spec_att(child.condition)
                    spec -= 1
                else:
                    remove_random_spec_att(diff)
                    spec_new -= 1
        else:
            while spec + spec_new > cons.beta:
                remove_random_spec_att(diff)
                spec_new -= 1
        child.condition = diff
        if child.q < 0.5:
            child.q = 0.5
        child.exp = 1
        assert isinstance(child, Classifier), 'Should be a Classifier'
        return child
开发者ID:masterchef8,项目名称:ACS2,代码行数:35,代码来源:ACS2.py

示例2: gen_match_set

# 需要导入模块: from Classifier import Classifier [as 别名]
# 或者: from Classifier.Classifier import condition [as 别名]
def gen_match_set(pop: list, percept: list):
    """
    Generate a list of Classifier thats match current perception
    :param pop:
    :type pop: list
    :param percept:
    :type percept: list
    :return:
    :rtype: list
    """
    ma = []
    if time == 0 or len(pop) == 0:
        for i in range(cons.nbAction):
            newcl = Classifier()
            newcl.condition = [cons.symbol] * cons.lenCondition
            newcl.action = i
            newcl.effect = [cons.symbol] * cons.lenCondition
            newcl.exp = 0
            newcl.t = time
            newcl.q = 0.5
            pop.append(newcl)
    for c in pop:
        if does_match(c, percept):
            ma.append(c)
    return ma
开发者ID:masterchef8,项目名称:ACS2,代码行数:27,代码来源:ACS2.py

示例3: generate_covering_classifier

# 需要导入模块: from Classifier import Classifier [as 别名]
# 或者: from Classifier.Classifier import condition [as 别名]
def generate_covering_classifier(env, action):
    newcl = Classifier()
    newcl.condition = ['0'] * len(env)

    for i in range(len(env)):
        if rd.random() < cons.P_dontcare:
            newcl.condition[i] = cons.dontCare
        else:
            newcl.condition[i] = env[i]
    for i in range(len(action)):
        if action[i] is False:
            newcl.action = i
    newcl.prediction = cons.predictionIni
    newcl.predictionError = cons.predictionErrorIni
    newcl.fitness = cons.fitnessIni
    newcl.experience = 0
    newcl.timeStamp = time
    newcl.actionSetSize = 1
    newcl.numerosity = 1
    return newcl
开发者ID:masterchef8,项目名称:XCS,代码行数:22,代码来源:XCS.py


注:本文中的Classifier.Classifier.condition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。