예제 #1
0
def predict_wins_by_ratio(data_cut = 100, plot = True):
    players, _ = tools.create_stats(data_cut)
    _, games = tools.read_db()

    predictions = []
    results = []

    for game in games[data_cut:]:
        team_red = Team()
        team_black = Team()

        for player in players:
                if player['id'] == game['red0'] or player['id'] == game['red1']:
                    team_red.add_player(player)
    
                if player['id'] == game['black0'] or player['id'] == game['black1']:
                    team_black.add_player(player)
        

        probability = team_red.strength_by_goals / (team_red.strength_by_goals + team_black.strength_by_goals)
        predictions.append(probability)

        if (game['score_red'] > game['score_black']):
            results.append(1)
        else:
            results.append(0)

    predictions = np.array(predictions)
    results = np.array(results)
    MAE = np.mean(np.abs(predictions - results))
    if plot:
        print MAE
    return MAE
예제 #2
0
def predict_random_goals(data_cut = 100, plot = True):
    players, _ = tools.create_stats(data_cut)
    _, games = tools.read_db()

    predictions = []
    results = []

    for game in games[data_cut:]:
        team_red = Team()
        team_black = Team()

        for player in players:
                if player['id'] == game['red0'] or player['id'] == game['red1']:
                    team_red.add_player(player)
    
                if player['id'] == game['black0'] or player['id'] == game['black1']:
                    team_black.add_player(player)
        
        if np.random.rand() > 0.5:
            predictions.append(6 - np.random.randint(0,6))
        else:
            predictions.append(np.random.randint(0,6) - 6)

        if (game['score_red'] > game['score_black']):
            results.append(1)
        else:
            results.append(0)

    predictions = np.array(predictions)
    results = np.array(results)
    MAE = np.mean(np.abs(predictions - results))
    if plot:
        print MAE
    return MAE
예제 #3
0
def predict_goals_by_effictivity(data_cut = 100, plot = True):
    players, _ = tools.create_stats(data_cut)
    _, games = tools.read_db()

    predictions = []
    results = []

    for game in games[data_cut:]:
        team_red = Team()
        team_black = Team()

        for player in players:
                if player['id'] == game['red0'] or player['id'] == game['red1']:
                    team_red.add_player(player)
    
                if player['id'] == game['black0'] or player['id'] == game['black1']:
                    team_black.add_player(player)
        
        effectivity_red = team_red.offensive_strength_by_time # * team_black.defensive_strength_by_time
        effectivity_black = team_black.offensive_strength_by_time # * team_red.defensive_strength_by_time

        if effectivity_red > effectivity_black:
            predicted_score_black = effectivity_black / effectivity_red * 6 

            predictions.append(6 - predicted_score_black)

            if plot:
                print "Prediction: red wins 6:" + str(int(round(predicted_score_black))), " real outcome: ", str(game['score_red']) + ":" + str(game['score_black'])  
        else:
            predicted_score_red = effectivity_red / effectivity_black * 6 

            predictions.append(predicted_score_red - 6)

            if plot:
                print "Prediction: black wins 6:" + str(int(round(predicted_score_red))), " real outcome: ", str(game['score_black']) + ":" + str(game['score_red'])

        results.append(game['score_red'] - game['score_black'])

    predictions = np.array(predictions)
    results = np.array(results)
    MAE = np.mean(np.abs(predictions - results))
    if plot:
        print MAE
    return MAE
예제 #4
0
def loadReminders(self):
    try:
        self.reminders = read_db(self, 'tell')
    except GrumbleError:
        self.reminders = {}
예제 #5
0
파일: remind.py 프로젝트: goavki/phenny
def load_database(phenny):
    try:
        return read_db(phenny, 'reminders')
    except GrumbleError:
        return {}
예제 #6
0
def loadAliases(self):
    try:
        nick_aliases = read_db(self, 'alias')
    except GrumbleError:
        nick_aliases = []
예제 #7
0
파일: remind.py 프로젝트: evo938938/gracie
def load_database(phenny):
    try:
        return read_db(phenny, 'reminders')
    except GrumbleError:
        return {}
예제 #8
0
파일: tell.py 프로젝트: goavki/phenny
def loadAliases(self):
    try:
        nick_aliases = read_db(self, 'alias')
    except GrumbleError:
        nick_aliases = []
예제 #9
0
파일: tell.py 프로젝트: goavki/phenny
def loadReminders(self):
    try:
        self.reminders = read_db(self, 'tell')
    except GrumbleError:
        self.reminders = {}
예제 #10
0
def setup(phenny):
    try:
        phenny.queue_data = read_db(phenny, 'queue')
    except GrumbleError:
        logger.debug('queue database read failed, initializing data')
        phenny.queue_data = {}
예제 #11
0
파일: queue.py 프로젝트: goavki/phenny
def setup(phenny):
    try:
        phenny.queue_data = read_db(phenny, 'queue')
    except GrumbleError:
        logger.debug('queue database read failed, initializing data')
        phenny.queue_data = {}