def load_stats(): stats = [] for pub in test_imgsets.keys(): for window in windows: for region in regions: for training_set_size in training_set_sizes: for image_number in test_imgsets[pub]: stat = load_stat(image_number, pub, window, training_set_size, region) stats.append(stat) stat["pub"] = pub stat["window"] = window stat["training_set_size"] = training_set_size stat["image"] = image_number stat["region"] = region return stats
def handle_stats(args, channel, user_id): year, heading = _coerce_year(args, "%s Stats") stmts = Statement.query.filter(Statement.veracity.isnot(None)) stmts = _maybe_filter_stmts_for_year(stmts, year) stmts = stmts.order_by(Statement.timestamp).all() stats = [] getters = _STAT_GETTERS[:] random.shuffle(getters) for getter in [_get_count] + getters[:]: stat = getter(stmts) if isinstance(stat, (list, tuple)): stats.extend(stat) else: stats.append(stat) return '{}:{}'.format(heading, ''.join(f'\n- {s}' for s in stats))
def normalizeData(self, data): # create an empty list stats = list() player_ids = data.keys() for player_id in player_ids: self.players.append(player_id) player_data = data[player_id] if type(player_data) == type({}): player_data['id'] = self.game_id player_data['player_id'] = player_id player_data['year'] = self.year stats.append(player_data) return stats
def rank_players(self, pos, stat): stats = [] playerlst = [] if pos !='DST': for x in self.players: if self.players[x]['Position'] == pos: playerlst.append(x) for x in playerlst: stats.append( (x,self.players[x][stat]) ) if stat == 'Overall': sortedstats = sorted(stats,key=lambda tup: tup[1]) else: sortedstats = sorted(stats,key=lambda tup: tup[1],reverse=True) rank = 1 for x in sortedstats: self.players[x[0]][stat+'rank'] = rank rank = rank + 1
def get_stat(db, stat, distortions): stats = [] for d in distortions: res = np.array(map(float, np.array(db.query("SELECT " + stat + " FROM stats WHERE image LIKE \"" + d + "_76%\"")).flatten())) stats.append([res.mean(), np.sqrt(res.var()), d]) return np.array(stats)