當前位置: 首頁>>代碼示例>>Python>>正文


Python KeyboardStrategy.read方法代碼示例

本文整理匯總了Python中soccersimulator.KeyboardStrategy.read方法的典型用法代碼示例。如果您正苦於以下問題:Python KeyboardStrategy.read方法的具體用法?Python KeyboardStrategy.read怎麽用?Python KeyboardStrategy.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在soccersimulator.KeyboardStrategy的用法示例。


在下文中一共展示了KeyboardStrategy.read方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build_apprentissage

# 需要導入模塊: from soccersimulator import KeyboardStrategy [as 別名]
# 或者: from soccersimulator.KeyboardStrategy import read [as 別名]
def build_apprentissage(fn,generator):
    ex_raw = KeyboardStrategy.read(fn)
    exemples = []
    labels = []
    for x in ex_raw:
        exemples.append(generator(x[1],x[0][0],x[0][1]))
        labels.append(x[0][2])
    return exemples,labels
開發者ID:jordanupmc,項目名稱:soccersimulator,代碼行數:10,代碼來源:decisiontree.py

示例2: build_apprentissage

# 需要導入模塊: from soccersimulator import KeyboardStrategy [as 別名]
# 或者: from soccersimulator.KeyboardStrategy import read [as 別名]
#gen_features.names = ["ball_dist","distance ball my goal","distance ball his goal","hisgoal_dist","mygoal_dist","dist adv le plus proche","nb adv autour"]

def build_apprentissage(fn,generator):
    ex_raw = KeyboardStrategy.read(fn)
    exemples = []
    labels = []
    for x in ex_raw:
        exemples.append(generator(x[1],x[0][0],x[0][1]))
        labels.append(x[0][2])
    return exemples,labels

def apprendre_arbre(train,labels,depth=5,min_samples_leaf=2,min_samples_split=2):
    tree= DecisionTreeClassifier(max_depth=depth,min_samples_leaf=min_samples_leaf,min_samples_split=min_samples_split)
    tree.fit(train,labels)
    return tree

## Match d'entrainement et apprentissage de l'arbre
if True:
    #match = SoccerMatch(team_noob,team_bad,1000)
    #show(match)
    ## Sauvegarde des exemples, mettre False a True si concatenation des fichiers
    #strat.write("test.tree",True)
    ## Lecture du fichier cree
    exemples = KeyboardStrategy.read("./training.exp")
    ## constitution de la base d'entrainement et des labels
    train,labels = build_apprentissage("./training.exp",gen_features)
    ## apprentissage de l'arbre
    tree = apprendre_arbre(train,labels)
    ## sauvegarde de l'arbre
    cPickle.dump(tree,file("tree.pkl","w"))
開發者ID:Asparodia,項目名稱:soccersimulator,代碼行數:32,代碼來源:tree_2v2.py

示例3: aux

# 需要導入模塊: from soccersimulator import KeyboardStrategy [as 別名]
# 或者: from soccersimulator.KeyboardStrategy import read [as 別名]
    long = 10
    sep1="|"+"-"*(long-1)
    sepl="|"+" "*(long-1)
    sepr=" "*long
    def aux(node,sep):
        if tree.tree_.children_left[node]<0:
            ls ="(%s)" % (", ".join( "%s: %d" %(tree.classes_[i],int(x)) for i,x in enumerate(tree.tree_.value[node].flat)))
            return sep+sep1+"%s\n" % (ls,)
        return (sep+sep1+"X%d<=%0.2f\n"+"%s"+sep+sep1+"X%d>%0.2f\n"+"%s" )% \
                (tree.tree_.feature[node],tree.tree_.threshold[node],aux(tree.tree_.children_left[node],sep+sepl),
                tree.tree_.feature[node],tree.tree_.threshold[node],aux(tree.tree_.children_right[node],sep+sepr))
    return aux(0,"")



exemples = KeyboardStrategy.read("./monfichier.exp")
train,labels = build_apprentissage("./monfichier.exp",gen_features)
tree = apprendre_arbre(train,labels)
print(affiche_arbre(tree))





if __name__=="__main__":
    prefix = "./test"
    if len(sys.argv)>1:
        prefix = sys.argv[1]
    ## constitution de la base d'entrainement et des labels
    train,labels = build_apprentissage(prefix+".exp",gen_features)
    ## apprentissage de l'arbre
開發者ID:ad50144124,項目名稱:mon_projet,代碼行數:33,代碼來源:decisiontree.py


注:本文中的soccersimulator.KeyboardStrategy.read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。