-
Notifications
You must be signed in to change notification settings - Fork 0
/
anomaly.py
61 lines (57 loc) · 3.66 KB
/
anomaly.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class AbnormalPlayers(object):
@classmethod
def getPlayers(cls, playerdb, rechargedb):
box = do(playerdb.get_all_basic(),
cls.removeKnownCheaters,
cls.playerBasics,
)
return cls.addPayment(rechargedb, box)
@classmethod
def removeKnownCheaters(cls, players):
cheaters = {"1-15-7051691", "1-15-15012711", "1-15-35709197", "1-15-2447822", "1-15-39179059", "1-15-16806291",
"1-15-35688053", "1-15-39134981", "1-15-49919157", "1-10-10863685", "1-15-12639571", "1-10-3870258",
"1-15-47339805", "1-67-cpd1346740", "1-33-14560350", "1-15-21356833", "1-31-5912410",
"1-15-46208447", "1-67-cpd592550", "1-15-31849353", "1-15-42349645", "1-16-s5565aa4ebaa4b",
"2-33-14566586", "1-33-14577222", "1-15-49923589", "1-67-cpd1346740", "1-15-21356833",
"1-33-14560350", "1-15-47339805", "1-31-5912410", "1-16-s5565d9ff48e59", "1-15-31849353",
"1-15-42349645", "1-16-s5565aa4ebaa4b", "1-15-17142427", "3-10-1685822", "1-15-21356833",
"1-15-7051691", "1-15-15012711", "1-15-35709197", "1-15-2447822", "1-15-39179059", "1-15-16806291",
"1-15-35688053", "1-15-39134981", "1-15-49919157", "1-10-10863685", "1-15-12639571", "3-10-1685822",
"1-15-21356833", "1-15-47339805", "1-31-5912410", "1-67-cpd1346740", "2-33-14566586",
"2-16-s5566f5d8b511d", "4-30-5267843", "4-30-3558877", "4-30-5267843", "1-15-47339805",
"1-15-21356833", "3-31-5983421", "2-33-14566586", "4-30-5267843", "1-33-14812983", "3-15-46371555",
"3-15-2124342", "2-30-4719275", "2-30-3533037", "1-15-31849353", "1-15-42349645",
"1-16-s5565aa4ebaa4b", "2-16-s5566f5d8b511d", "6-30-5295167", "1-15-21356833", "4-30-5267843",
"6-31-6068584", "2-33-14566586", "7-30-4588668", "2-33-14642531", "1-15-47339805", "1-15-7051691",
"1-15-35709197", "1-15-2447822", "1-15-39179059", "1-15-16806291", "1-15-35688053", "1-15-39134981",
"1-15-49919157", "1-10-10863685", "1-10-3870258", "1-16-s5565d9ff48e59", "1-33-14577222",
"1-15-49923589", "1-10-10349099", "2-33-14566586", "1-10-9068505", "7-30-4588668", "4-30-5267843",
"2-33-14642531", "5-10-10971267", "1-15-21356833", "2-33-14566586", "8-30-5311990", "8-33-14642531",
"6-10-5894495", "7-10-2172960", "3-31-5974581", "1-15-21356833"}
return do(players,
lambda players: filter(lambda p: p[0] not in cheaters, players),
)
@classmethod
def playerBasics(cls, players):
"""players = [(id, all numeric fields), ...]"""
return do(players,
lambda players: map(lambda arg: (arg[0], arg[1:]), players),
lambda box: filter(lambda box: sum(box[1]) != 120, box),
)
@classmethod
def normAndTrain(cls, box):
return do(box,
unzip,
lambda box: (box[0], numpy.log1p(box[1])),
lambda box: (box[0], numpy.asarray(box[1])),
lambda box: (box[0], box[1], Gaussian(box[1])),
)
@classmethod
def addPayment(cls, rechargedb, box):
paidPlayers = do(rechargedb.get_paid_players(),
lambda pairs: map(lambda x: (x[0], int(x[1])), pairs),
dict,
)
return do(box,
lambda boxes: map(lambda box: (box[0], box[1] + (paidPlayers.get(box[0], 0),)), boxes),
)