File size: 1,490 Bytes
7ff7aab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
from pathlib import Path
import json
from collections import Counter
import operator

import numpy as np
import matplotlib.pyplot as plt
from string import ascii_lowercase as alc
from string import ascii_uppercase as auc
 
# assign directory
directory = 'HFFiles'
arch_list = []
invalid_counter = 0

# iterate over files in directory
files = Path(directory).glob('*.json')
for file in files:
    f = open(file)
    try:
        data = json.load(f)
    except:
        # print(str(file) + " does not look like valid JSON.")
        invalid_counter += 1
        continue
    try:
        for i in data['architectures']:
            # print(i)
            arch_list.append(i[0])
    except:
        # print(str(file) + " does not contain architectures key.")
        invalid_counter += 1

    f.close()

my_dict = Counter(arch_list)
# print(my_dict)
print("\n")
print(str(invalid_counter) + " JSON files are invalid.")

for i in alc:
    del my_dict[i]
for i in auc:
    del my_dict[i]

causal_dict = {k:v for (k,v) in my_dict.items() if "Causal" in k}

sorted_causal_dict = dict(sorted(causal_dict.items(),key=operator.itemgetter(1),reverse=True))
sorted_causal_dict = {key:val for key, val in sorted_causal_dict.items() if val != 1}

print(sorted_causal_dict)

labels, values = zip(*sorted_causal_dict.items())

indexes = np.arange(len(labels))
width = 1

plt.figure(figsize=(16,9))
plt.bar(indexes, values, width)
plt.xticks(indexes + width * 0.5, labels)
plt.xticks(rotation=90)
plt.show()