Skip to content

Commit

Permalink
Applies suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raahul Singh committed Jun 10, 2020
1 parent 209b597 commit c62070a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pythia/seo/elo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
import numpy as np
from collections import deque


class ELO:
Expand Down Expand Up @@ -103,9 +104,9 @@ def score_update(self, image_0, image_1, score_for_image_0):
"""
# state dicts
state_dict_0 = self.rankings.loc[image_0].to_dict()
state_dict_0['last_scores'] = list(map(float, state_dict_0['last_scores'].split(',')))
state_dict_0['last_scores'] = deque(map(float, state_dict_0['last_scores'].split(',')), maxlen=self.score_memory)
state_dict_1 = self.rankings.loc[image_1].to_dict()
state_dict_1['last_scores'] = list(map(float, state_dict_1['last_scores'].split(',')))
state_dict_1['last_scores'] = deque(map(float, state_dict_1['last_scores'].split(',')), maxlen=self.score_memory)

expected_score_0 = self.expected_score(self.rankings.loc[image_0]['score'],
self.rankings.loc[image_1]['score'])
Expand All @@ -119,15 +120,10 @@ def score_update(self, image_0, image_1, score_for_image_0):
state_dict_0['last_scores'].append(new_rating_0)
state_dict_1['last_scores'].append(new_rating_1)

if len(state_dict_0['last_scores']) > self.score_memory:
state_dict_0['last_scores'].pop(0)
if len(state_dict_1['last_scores']) > self.score_memory:
state_dict_1['last_scores'].pop(0)

new_std_dev_0 = min(np.std(state_dict_0['last_scores']), 1000000) # prevents Infinity
new_std_dev_0 = min(np.std(state_dict_0['last_scores']), 1_000_000) # prevents Infinity
new_k_0 = min(max(new_std_dev_0, self.score_change['min']), self.score_change['max'])

new_std_dev_1 = min(np.std(state_dict_1['last_scores']), 1000000) # prevents Infinity
new_std_dev_1 = min(np.std(state_dict_1['last_scores']), 1_000_000) # prevents Infinity
new_k_1 = min(max(new_std_dev_1, self.score_change['min']), self.score_change['max'])

# Updating Data
Expand Down

0 comments on commit c62070a

Please sign in to comment.