forked from signalab/ProtonPack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDistribution.py
37 lines (31 loc) · 1 KB
/
Distribution.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
import matplotlib.pyplot as plt
import pandas as pd
def getScoresFrequency():
df = pd.read_csv(input('Please insert the name of the csv file: ')) #df = DataFrame
scoresColumn = df.Score #scoresColumn = Series
scoreCountSet = set() # set of tuples
#Fill the set
for score in scoresColumn:
if score != 'Null':
scoreCountSet.add((score,1))
#Check frequency for each score
for score in scoresColumn:
for tup in scoreCountSet:
if tup[0] == score:
scoreValue = tup[1]
scoreCountSet.remove(tup)
newTup = (score, scoreValue + 1);
scoreCountSet.add(newTup)
break
return scoreCountSet
def plotScores():
scoresData = getScoresFrequency()
plt.scatter(*zip(*scoresData))
plt.title('Accounts distribution for bot probability\n')
plt.xlabel("Bot Probability")
plt.ylabel("Accounts")
plt.show()
def main():
plotScores()
if __name__ == '__main__':
main()