コード例 #1
0
def plot_shots(ax):
    from db.prozoneDB import DB
    c = DB.c
    rows = c.execute("""select eventtime from eventstream
              where (eventname='Shot on target' or eventname='Shot not on target')
              and matchid = ? and halfid = ?""",(matchid,1 if startm < 45 else 2)).fetchall()
    print(rows)
    shottimes = [to_minutes(t) if startm < 45 else to_minutes(t+45*60*1000)
                 for (t,) in rows if t > time[start] and t < time[start+step]]
    ax.scatter(shottimes,[0 for t in shottimes],s=200,c="orange",label="Shot")
    ax.legend()
コード例 #2
0
def plot_shotprob(ax=None):
    x = [to_minutes(t) if h==1 else to_minutes(t) + 45
         for t,h in zip(time[start:start+step],half[start:start+step])]
    zipped = list(zip(fcb[start:start+step],
                shotprobdom[start:start+step],
                shotprobother[start:start+step]))
    fcbprob = [a if f == 1 else b for f,a,b in zipped]
    otherprob = [-a if f== 0 else -b for f,a,b in zipped]
    ax.plot(x,fcbprob)
    ax.plot(x,otherprob)
    ax.plot(x,[0 for _i in x])
    ax.set_xlabel("Time (minutes)")
    ax.set_ylabel("Shotprobability in the next " + str(C.CLASS_WINDOW_SIZE) + " seconds")
コード例 #3
0
def find_peaks(doSmooth=False):
    x = [to_minutes(t) if h==1 else to_minutes(t) + 45
         for t,h in zip(time[start:start+step],half[start:start+step])]
    zipped = list(zip(fcb[start:start+step],
                goalprobdom[start:start+step],
                goalprobother[start:start+step]))
    fcbprob = [a if f == 1 else b for f,a,b in zipped]
    otherprob = [-a if f== 0 else -b for f,a,b in zipped]
    #y = exp_smooth(fcbprob,alpha=0.1) if doSmooth else fcbprob
    y = smooth(fcbprob,beta=4) if doSmooth else fcbprob
    peaks = detect_peaks(y,mph=0.003,mpd=12,show=True)
    print([x[peak] for peak in peaks])
    y = smooth(otherprob,beta=4) if doSmooth else otherprob
    peaks = detect_peaks(y,mph=0.003,mpd=12,show=True,valley=True)
    print([x[peak] for peak in peaks])
コード例 #4
0
ファイル: test.py プロジェクト: TomDecroos/thesis
def get_goalprob(halfid,doSmooth = False):
    x = np.array([to_minutes(t) if h==1 else to_minutes(t) + 45
         for t,h in zip(time,half) if h==halfid])
    zipped = [(f,a,b) for f,a,b,h in zip(fcb,
                goalprobdom,
                goalprobother,
                half
                ) if h == halfid]
    fcbprob = [a if f == 1 else b for f,a,b in zipped]
    otherprob = [a if f== 0 else b for f,a,b in zipped]
    teama = smooth(fcbprob,beta=4) if doSmooth else fcbprob
    teamb = smooth(otherprob,beta=4) if doSmooth else otherprob
    plotPredictions(x,teama,teamb)
    plt.show()
    return x,teama,teamb
コード例 #5
0
def plot_goalprob(ax=None,doSmooth = False):
    x = [to_minutes(t) if h==1 else to_minutes(t) + 45
         for t,h in zip(time[start:start+step],half[start:start+step])]
    zipped = list(zip(fcb[start:start+step],
                goalprobdom[start:start+step],
                goalprobother[start:start+step]))
    fcbprob = [a if f == 1 else b if f == -1 else 0 for f,a,b in zipped]
    otherprob = [-a if f== -1 else -b if f == 1 else 0 for f,a,b in zipped]
    #y = exp_smooth(fcbprob,alpha=0.1) if doSmooth else fcbprob
    y = smooth(fcbprob,beta=4) if doSmooth else fcbprob
    ax.plot(x,y,label="Team A")
    #y = exp_smooth(otherprob,alpha=0.1) if doSmooth else otherprob
    y = smooth(otherprob,beta=4) if doSmooth else otherprob
    ax.plot(x,y,label="Team B")
    ax.legend(loc=4)
    ax.plot(x,[0 for _i in x])
    ax.set_ylim(-0.02,0.02)
    ax.set_xlabel("Time (minutes)")
    ax.set_ylabel("Goalprobability in the next " + str(C.CLASS_WINDOW_SIZE) + " seconds")