예제 #1
0
 def pick(self, idx):
     limit = tools.threshold(self.no, self.judges())
     logic = (self.data.loc[idx, 'Total'] +
              self.data.loc[idx, 'Penalty']) >= limit
     self.data.loc[idx, 'Penalty'] = self.data.loc[idx, 'Penalty'].where(
         logic, limit - self.data.loc[idx, 'Total']).where(
             self.data.loc[idx, 'Total'] < limit, 0)
     return self.data
예제 #2
0
 def ban(self, idx):
     limit = tools.threshold(self.no, self.judges())
     logic = (self.data.loc[idx, 'Total'] +
              self.data.loc[idx, 'Penalty']) < limit
     self.data.loc[idx, 'Penalty'] = self.data.loc[idx, 'Penalty'].where(
         logic, (self.data.loc[idx, 'Total'] - (limit - 1)) * -1).where(
             self.data.loc[idx, 'Total'] >= limit, 0)
     return self.data
예제 #3
0
 def sort(self):
     data = self.data
     threshold = tools.threshold(self.no, self.judges())
     data = data.assign(Penaltized=data['Total'] +
                        data['Penalty']).sort_values(
                            ['Penaltized', 'ID', 'Penalty'],
                            ascending=[False, True, False])
     logic = data['Penaltized'] >= threshold
     self.data = tools.pd.concat(
         [data.loc[logic].sort_index(),
          data.loc[~logic].sort_index()]).drop('Penaltized', axis=1)
from model.constants import *
from model import tools
import numpy as np
import math
import glob

if __name__ == "__main__":

    MIN_NUMBER_SAMPLES = 30  # sample rate is 2samples/sec
    for file_path in glob.iglob('../data/classes/**/*.dat', recursive=True):
        if 'threshold' not in file_path and 'day' in file_path:
            data = tools.load_data_scilab(file_path)
            data = tools.convert(data)
            threshold_data = tools.threshold(data)
            if np.shape(threshold_data[:, 0])[0] > MIN_NUMBER_SAMPLES:
                threshold_file_path = '{}_threshold.dat'.format(
                    file_path.rstrip('.dat'))
                print('Applying thresholds to {} and storing in {}'.format(
                    file_path, threshold_file_path))
                with open(threshold_file_path, 'wb') as outfile:
                    np.save(outfile, threshold_data)
예제 #5
0
 def threshold(self):
     no = self.cur_stage_no()
     nJudges = len(self.judges)
     return tools.threshold(no, nJudges)
예제 #6
0
 def highlights(self):
     no = self.no
     nJudges = self.judges()
     threshold = tools.threshold(no, nJudges)
     return [tools.invalid_candidates(self.data, threshold)]
예제 #7
0
 def validity(self, idx):
     ''' return valid, invalid counts '''
     threshold = tools.threshold(self.no, self.judges())
     invalid = self.data['Total'] + self.data['Penalty'] < threshold
     return (~invalid).loc[idx].sum(), invalid.loc[idx].sum()
예제 #8
0
 def dropped(self, is_overall=False):
     threshold = tools.threshold(self.no, self.judges())
     sliced = self.data.iloc[:self.manpl.get(
     )] if not is_overall else self.data
     logic = (sliced['Total'] + sliced['Penalty']) < threshold
     return logic.sum()