Beispiel #1
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)
Beispiel #2
0
    def __predict(self, extractor: WikipediaExtractor) -> Dict[Player, float]:
        """ Execute the prediction phase of the Wikipedia Layer.

        Arguments:
            extractor (WikipediaExtractor): The extractor which delivers the prediction data.

        Returns:
            A dictionary with as key the players that participated in the prediction season and as value the likelihood
            of being the Mol.
        """
        predict_input = extractor.get_predict_data()
        predict_output = {p: self.__lower_likelihood if pi else 1.0 for p, pi in predict_input.items()}
        return predict_output
Beispiel #3
0
RANDOM_SEED = 949019755
SEASONS = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}
PCA_COMPONENTS = 5
UNLIKELY_Z_SCORE = 0.0

progress_bar = Bar("Distributions Computed:", max = len(SEASONS))

non_mol_outliers = 0
mol_outliers = 0
non_mol_inliers = 0
mol_inliers = 0

for season in SEASONS:
    random_generator = RandomState(RANDOM_SEED)
    train_seasons = SEASONS.difference({season})
    extractor = WikipediaExtractor(season, train_seasons, PCA_COMPONENTS, UNLIKELY_Z_SCORE, random_generator)
    extractor.train()
    predict_input = extractor.get_predict_data()
    for player, is_outlier in predict_input.items():
        if is_outlier[0]:
            if get_is_mol(player):
                mol_outliers += 1
            else:
                non_mol_outliers += 1
        else:
            if get_is_mol(player):
                mol_inliers += 1
            else:
                non_mol_inliers += 1
    progress_bar.next()
Beispiel #4
0
from Data.PlayerData import get_is_mol
from Layers.Appearance.AppearanceLayer import InnerAppearanceLayer
from Layers.Wikipedia.WikipediaExtractor import WikipediaExtractor
from numpy.random.mtrand import RandomState
from scipy.stats import kruskal, levene, norm
import matplotlib.pyplot as plt
import numpy as np

TRAIN_SEASONS = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
PREDICT_SEASON = 5
TRAIN_SEASONS.difference_update({PREDICT_SEASON})
RANDOM_SEED = 949019755
PCA_COMPONENTS = 4
LOWER_Z_SCORE = -0.674

extractor = WikipediaExtractor(PREDICT_SEASON, TRAIN_SEASONS, PCA_COMPONENTS,
                               RandomState(RANDOM_SEED))
train_input, train_output = extractor.get_train_data()
train_input = np.squeeze(train_input)

mol_features = [
    value for value, is_mol in zip(train_input, train_output) if is_mol == 1.0
]
non_mol_features = [
    value for value, is_mol in zip(train_input, train_output) if is_mol == 0.0
]
_, mean_p_value = kruskal(mol_features, non_mol_features)
_, std_p_value = levene(mol_features, non_mol_features)
print("Mean: " + str(mean_p_value) + ", Std: " + str(std_p_value))

mol_kde = InnerAppearanceLayer.kernel_density_estimation(mol_features)
non_mol_kde = InnerAppearanceLayer.kernel_density_estimation(non_mol_features)