#!/usr/bin/env python3 #spencer jackson #find games that could be higher ranked if they just got more ratings import bgg_get_game_stats as bggstats import bgg_top_ranked as bggtr import numpy as np import matplotlib.pyplot as matplot import regression as reg top = bggtr.getTopRankedGames(100) stats = bggstats.getStatsSlowly(top) filterwidth = 46 smoothwidth = 5 #keep this odd nvotes = stats[:,bggstats.voters_col].astype(np.int) print("med" ,np.median(nvotes),"mean", np.mean(nvotes)) exit() l = stats.shape[0] #this could maybe be done with broadcasting but I'd have to look it up medvotes = np.r_[:l-filterwidth] for i in range(l-filterwidth): medvotes[i] = np.median(nvotes[i:i+filterwidth]) size = l-filterwidth - smoothwidth +1 smoothvotes = np.r_[:size] #another pass to smooth it further for i in range(size): smoothvotes[i] = np.mean(medvotes[i:i+smoothwidth])
import bgg_get_game_stats as bggstats import bgg_most_played as bggmp import numpy as np import matplotlib.pyplot as matplot ntop = 10 monthwindow = 12 year = 20 month = 4 unpub = 18291 top = bggmp.getTopPlayedGamesTill(year, month, monthwindow, 10) #top played top = top[top[:, bggmp.gameid_col] != unpub, :] #exclude unpublished prototype idlist = top[:, bggmp.gameid_col] stats = bggstats.getStatsSlowly(idlist) #top and stats should be aligned so the id cols match print(top.shape, stats.shape) print(type(top[0, bggmp.gameid_col])) #int print(type(stats[0, bggstats.gameid_col])) #str for i in range(top.shape[0]): #if top[i, bggmp.gameid_col] != stats[i, bggstats.gameid_col]: a = int(top[i, bggmp.gameid_col]) b = int(stats[i, bggstats.gameid_col]) # if int(top[i, bggmp.gameid_col]) != stats[i, bggstats.gameid_col]: if a != b: print(i, a, b) print(i, int(top[i, bggmp.gameid_col]), stats[i, bggstats.gameid_col]) print("oh no! The fetched data doesn't match!")