Ejemplo n.º 1
0
class HeroSetFeatureExtractor(object):
    """Extracts features related to a set of heros."""
    def __init__(self):
        super(HeroSetFeatureExtractor, self).__init__()
        self.hfe = HeroFeatureExtractor()

    def extract(self, heroes):
        hero_features = [self.hfe.extract(hero) for hero in heroes]

        features = list()
        for values in zip(*hero_features):
            features.append(sum(values))
            features.append(max(values))
            features.append(min(values))
            features.append(numpy.median(values))
            features.append(numpy.prod(values))

        return features

    def extractFeatureNames(self):
        feature_names = list()
        for feature_name in self.hfe.extractFeatureNames():
            fxns = ["sum", "max", "min", "median", "product"]
            for fxn in fxns:
                feature_names.append("%s_%s" % (fxn, feature_name))

        return feature_names
Ejemplo n.º 2
0
class TestHeroFeatureExtractor(unittest2.TestCase):
    def setUp(self):
        self.hfe = HeroFeatureExtractor()

    def test_output(self):
        output = dict()

        for name, value in zip(self.hfe.extractFeatureNames(),
                               self.hfe.extract("Abaddon")):
            output[name] = value

        self.assertEqual(len(self.hfe.extractFeatureNames()),
                         len(self.hfe.extract("Abaddon")))

        self.assertEqual(output["STR"], 23)
        self.assertEqual(output["STR+"], 2.7)
        self.assertEqual(output["HP/S"], 0.25)
        self.assertEqual(output["LVL 25"], 216)

        self.assertEqual(output["FARM PRIORITY"], 0.088)
Ejemplo n.º 3
0
 def setUp(self):
     self.hfe = HeroFeatureExtractor()
Ejemplo n.º 4
0
 def __init__(self):
     super(HeroSetFeatureExtractor, self).__init__()
     self.hfe = HeroFeatureExtractor()