Created
March 15, 2017 05:04
-
-
Save anandology/5a19f29c31a5605b2011f5c3aec7cec7 to your computer and use it in GitHub Desktop.
Script to find most common features found from multiple runs of an algorithm with different parameters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Script to find most common features found from | |
multiple runs of an algorithm with different parameters. | |
""" | |
from collections import Counter | |
runs = [ | |
["a", "b", "c", "d", "e"], | |
["a", "b", "c", "d", "f"], | |
["a", "b", "c", "e", "g"], | |
["a", "b", "d", "f", "h"] | |
] | |
# approach 1 | |
c = Counter() | |
for features in runs: | |
c.update(features) | |
print(c.most_common(5)) | |
# approach 2 | |
all_features = [f for features in runs for f in features] | |
print(all_features) | |
c = Counter(all_features) | |
print(c.most_common(5)) | |
# print just the top features without the counts | |
top_features = [f for f, count in c.most_common(5)] | |
print(top_features) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment