def calculate_features(situation, data): """Generate features needed for the win probability model that are not contained in the general game state information passed via API. Parameters ---------- situation : OrderedDict Returns ------- situation : The same OrderedDict, with new keys and values. """ situation['kneel_down'] = p.kneel_down(situation['score_diff'], situation['timd'], situation['secs_left'], situation['dwn']) situation['qtr'] = qtr(situation['secs_left']) situation['qtr_scorediff'] = situation['qtr'] * situation['score_diff'] situation['spread'] = ( situation['spread'] * (situation['secs_left'] / 3600)) cum_pct = ( (situation['secs_left'] - data['final_drives'].secs).abs().argmin()) situation['poss_prob'] = data['final_drives'].ix[cum_pct].cum_pct return situation
def calculate_features(situation): """Generate features needed for the win probability model that are not contained in the general game state information passed via API. Parameters ---------- situation : OrderedDict Returns ------- situation : The same OrderedDict, with new keys and values. """ situation['kneel_down'] = p.kneel_down(situation['score_diff'], situation['timd'], situation['secs_left'], situation['dwn']) situation['qtr'] = qtr(situation['secs_left']) situation['qtr_scorediff'] = situation['qtr'] * situation['score_diff'] situation['spread'] = ( situation['spread'] * (situation['secs_left'] / 3600)) return situation
def calculate_features(situation, data): """Generate features needed for the win probability model that are not contained in the general game state information passed via API. Parameters ---------- situation : OrderedDict Returns ------- situation : The same OrderedDict, with new keys and values. """ situation['kneel_down'] = p.kneel_down(situation['score_diff'], situation['timd'], situation['secs_left'], situation['dwn']) situation['qtr'] = qtr(situation['secs_left']) situation['qtr_scorediff'] = situation['qtr'] * situation['score_diff'] situation['spread'] = (situation['spread'] * (situation['secs_left'] / 3600)) cum_pct = ((situation['secs_left'] - data['final_drives'].secs).abs().argmin()) situation['poss_prob'] = data['final_drives'].ix[cum_pct].cum_pct return situation