Пример #1
0
        self.nn = tups[0:self.k]
        return self.nn

class NearestNeighboursVP(NearestNeighboursAbstract):
    
    def __init__(self,windows,k=100,weighted=False,dist = custom_dtw_distance):
        self.vptree = VPTree(windows,dist)
        self.k = k
        self.weighted = weighted           
    
    def search_k_nearest_neighbours(self,window,log=True):
        self.nn = get_nearest_neighbors(self.vptree,window,self.k)
        return self.nn

if __name__ == '__main__':
    trainset = getAllWindows(5,10)
    testset = getAllWindows(0, 3)
    knn = NearestNeighboursBF(trainset,100,True)
    cnt = 0
    for window in testset:
        if window.is_goal() and cnt < 6:
            t0 = pc()
            result = knn.predict_shotprobgoalprob(window,log=True)
            print(result)
            print(window.is_defensive_error_shot())
            print(pc()-t0, "seconds elapsed")
            fig,ax = plt.subplots(5,5)
            window.plot(ax[0,0],False,False,True)
            for i in range(1,25):
                #print(knn.nn[i][0])
                knn.nn[i][1].plot(ax[i//5,i%5],False,False,True)
Пример #2
0
'''
Created on 16 Mar 2016

@author: Temp
'''
from eav.window import getAllWindows
from eav.event import Event
from db.prozoneDB import DB
import matplotlib.pyplot as plt
import numpy as np
import tools.logger as logger
c = DB.c

window = getAllWindows(0, 1)[1000]
virtual = window.events[0:21]
#for event in window.events[0:20]:
    #print(event.to_string())
    
time = window.get_time()
matchid = window.matchhalf.matchid
halfid = window.matchhalf.halfid

qry = """
select locationx, locationy,eventname,duel,teamid,idactor1,position,
eventid,eventtime 
from eventstream
where matchid = ? and halfid = ?
and eventtime > ? and eventtime < ? + 10000
"""
rows = c.execute(qry,(matchid,halfid,time,time)).fetchall()
#for row in rows: