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])
示例#2
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
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")