當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。