-
Notifications
You must be signed in to change notification settings - Fork 1
/
statistics.py
60 lines (55 loc) · 2.29 KB
/
statistics.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
def show_statistics_of_clusters(clusters):
cluster_with_size_1 = 0
cluster_with_size_2 = 0
cluster_about_computing = 0
big_clusters_about_computing = 0
number_of_clusters = len(clusters)
number_of_tweets = 0
number_of_tweets_about_computing = 0
number_of_processed_clusters = 0
for cluster in clusters:
number_of_tweets += len(cluster.tweets)
try:
if cluster.processed:
number_of_processed_clusters += 1
except AttributeError:
pass
if len(cluster.tweets) is 1:
cluster_with_size_1 += 1
if len(cluster.tweets) is 2:
cluster_with_size_2 += 1
if cluster.topic == "computing":
cluster_about_computing += 1
number_of_tweets_about_computing += len(cluster.tweets)
if len(cluster.tweets) > 2:
big_clusters_about_computing += 1
for cluster in clusters:
if cluster.topic == "computing":
cluster.describe()
print("Number of cluster with only one tweet " + str(cluster_with_size_1))
print("Number of cluster with only two tweets " + str(cluster_with_size_2))
print("Clusters about computing : " + str(cluster_about_computing) +
" (" + str(number_of_tweets_about_computing) + ")")
print("Among which " + str(cluster_about_computing) + " of clusters with more than 3 tweets")
print("Number of clusters " + str(number_of_clusters) + " (" + str(number_of_tweets) + ")")
print("Number of processed cluster " + str(number_of_processed_clusters))
def show_statistics_on_topic(clusters, topic):
true_positive = 0
true_negative = 0
false_positive = 0
false_negative = 0
for cluster in clusters:
if cluster.detected_topic == topic:
if cluster.topic == topic:
true_positive += 1
else:
false_positive += 1
else:
if cluster.topic == topic:
false_negative += 1
else:
true_negative += 1
print("There are " + str(true_positive) + " true positives.")
print("There are " + str(true_negative) + " true negatives.")
print("There are " + str(false_positive) + " false positives.")
print("There are " + str(false_negative) + " false negatives.")