def averageMatches(participant, matchList): length = 5 statVector = np.zeros(63) nonNorm = np.zeros(6) pulled = 0 rank = "" for matchRef in matchList: try: match = matchRef.match(include_timeline=True) except: print 'Match pull from reference failed.' continue hold = statVector try: for p in match.participants: if p.summoner.id == participant.summoner.id: try: rank = p.previous_season_tier.name except ValueError: rank = "unranked" statVector = np.add(statVector, np.array(parseMatch.getPStats(p, match))) nonNorm = np.add(nonNorm, np.array(parseMatch.getNonNorm(p, match))) pulled += 1 break except AttributeError: print 'Match parse failed.' statVector = hold if pulled > length-1: break return np.divide(statVector, pulled), np.divide(nonNorm, pulled), rank
def averageMatches(participant, matchList): ''' Process number of games equal to length, average performance Returns an averaged feature vector and a non-normalized vector for website ''' length = 5 statVector = np.zeros(63) #Length of feature vector nonNorm = np.zeros(6) #Length of stat vector passed to website pulled = 0 rank = "" for matchRef in matchList: try: match = matchRef.match(include_timeline=True) except: print 'Match pull from reference failed.' continue hold = statVector try: for p in match.participants: if p.summoner.id == participant.summoner.id: try: rank = p.previous_season_tier.name except ValueError: rank = "unranked" statVector = np.add(statVector, np.array(parseMatch.getPStats(p, match))) nonNorm = np.add(nonNorm, np.array(parseMatch.getNonNorm(p, match))) pulled += 1 break except AttributeError: print 'Match parse failed.' statVector = hold if pulled > length-1: break if pulled == 0: return None return np.divide(statVector, pulled), np.divide(nonNorm, pulled), rank