예제 #1
0
 def compute_distribution(self, predict_season: int, latest_episode: int,
                          train_seasons: Set[int]) -> Dict[Player, float]:
     equal_layer = EqualLayer()
     new_distribution = equal_layer.compute_distribution(
         predict_season, latest_episode, train_seasons)
     for layer in self.__layers:
         layer_distribution = layer.compute_distribution(
             predict_season, latest_episode, train_seasons)
         for player, likelihood in new_distribution.items():
             new_distribution[
                 player] = layer_distribution[player] * likelihood
     return new_distribution
예제 #2
0
    def compute_distribution(
            self, predict_season: int, latest_episode: int,
            train_seasons: Set[int]) -> Dict[Player, np.array]:
        all_predictions = self.__layer.predict(predict_season, latest_episode,
                                               train_seasons)
        if not all_predictions:
            return EqualLayer().compute_distribution(predict_season,
                                                     latest_episode,
                                                     train_seasons)

        distribution = dict()
        for player, predict in all_predictions.items():
            if predict.exclusion:
                distribution[player] = 0.0
            else:
                total_likelihood = 1.0
                for likelihood in predict.predictions:
                    total_likelihood *= likelihood
                distribution[player] = total_likelihood

        if self.__smoothness:
            for player, likelihood in distribution.items():
                number_predictions = len(all_predictions[player].predictions)
                distribution[player] = likelihood**self.get_smoothness_factor(
                    number_predictions)

        return distribution
예제 #3
0
    def compute_distribution(self, predict_season: int, latest_episode: int, train_seasons: Set[int]) -> Dict[Player, float]:
        available_seasons = self.seasons_with_data()
        if predict_season not in available_seasons:
            return EqualLayer().compute_distribution(predict_season, latest_episode, train_seasons)
        train_seasons = train_seasons.intersection(available_seasons)

        extractor = WikipediaExtractor(predict_season, train_seasons, self.__pca_components, self.__unlikely_z_score,
                                       self.__random_generator)
        extractor.train()
        return self.__predict(extractor)
예제 #4
0
 def compute_distribution(self, predict_season: int, latest_episode: int,
                          train_seasons: Set[int]) -> Dict[Player, float]:
     if predict_season in SUSPICION_DATA:
         exclude_players = SUSPICION_DATA[predict_season]
         distribution = dict()
         for player in get_players_in_season(predict_season):
             distribution[
                 player] = self.__EPSILON if player in exclude_players else 1.0
         return distribution
     else:
         return EqualLayer().compute_distribution(predict_season,
                                                  latest_episode,
                                                  train_seasons)
예제 #5
0
    def compute_distribution(self, predict_season: int, latest_episode: int, train_seasons: Set[int]) -> Dict[Player, float]:
        available_seasons = EXAM_DATA.keys()
        train_seasons = train_seasons.intersection(available_seasons)
        if predict_season not in available_seasons:
            return EqualLayer().compute_distribution(predict_season, latest_episode, train_seasons)

        estimator = self.__train(train_seasons)
        alive_players = EXAM_DATA[predict_season].get_alive_players(latest_episode)
        result = {player: 1.0 if player in alive_players else 0.0 for player in get_players_in_season(predict_season)}
        for episode in EXAM_DATA[predict_season].episodes.values():
            if episode.id > latest_episode or episode.result.drop != DropType.EXECUTION_DROP:
                continue
            prediction = self.__predict_for_episode(episode, alive_players, estimator)
            for player, likelihood in prediction.items():
                result[player] *= likelihood
        return result