Beispiel #1
0
def classify_windows():
    results = []
    t0 = pc()
    for window in testset:
        (shotprobdom,shotprobother),(goalprobdom,goalprobother) = \
            knn.predict_shotprobgoalprob(window)
        
        is_shot = 0
        if window.is_shot():
            is_shot = 1 if not window.is_defensive_error_shot() else -1
        is_goal = 0
        if window.is_goal():
            is_goal = 1 if not window.is_defensive_error_goal() else -1
            
        time = window.get_time()
        half = window.matchhalf.halfid
        dom_team = window.get_dominating_team()
        fcb = 1 if dom_team == "32311" else 0
        results.append([half,time,fcb,shotprobdom,shotprobother,is_shot,
                        goalprobdom,goalprobother,is_goal])
        np.savetxt(resultsdir + resultsfile,results)
        tx = time //1000
        if half ==2:
            tx+= 45*60
        ty = pc() - t0
        print("Time in-game:",logger.to_timestring(tx),\
              "CPU time:",logger.to_timestring(ty))
Beispiel #2
0
def load_all_matches(postfix="_dtw"):
    matchids = [m for (m,) in c.execute("select id from match order by id").fetchall()]

    logs = list()
    for matchid in matchids:
        filename = str(matchid) + postfix
        logfile = open("../../data/logs/" + filename, "r")
        logs.append(json.load(logfile))

    print logger.to_timestring(np.mean([log["construct classifier"] for log in logs]))
    print logger.to_timestring(np.mean([log["match classification"] for log in logs]))
    print np.mean([log["match classification"] for log in logs]) / 1125
Beispiel #3
0
 def classify_match():
     results = []
     for window in testset:
         result,classificationtime = logger.executeandtime(lambda:knn.predict_shotprobgoalprob(window,direct=direct))
         (shotprobdom,shotprobother),(goalprobdom,goalprobother) = result
             
         is_shot = 0
         if window.is_shot():
             is_shot = 1 if not window.is_defensive_error_shot() else -1
         is_goal = 0
         if window.is_goal():
             is_goal = 1 if not window.is_defensive_error_goal() else -1
             
         time = window.get_time()
         half = window.matchhalf.halfid
         dom_team = window.get_dominating_team()
         
         fcb = 1 if dom_team == "32311" else 0 if dom_team == "None" else -1
         results.append([half,time,fcb,shotprobdom,shotprobother,is_shot,
                         goalprobdom,goalprobother,is_goal,classificationtime])
             
         np.savetxt('../data/' + resultsfolder + "/" + folder + "/" + filename,results)
         tx = time //1000
         if half ==2:
             tx+= 45*60
         if tx%(60*15) in range(0,5) and v > 0:
             print "Time in-game:",logger.to_timestring(tx)