Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to find most common features found from multiple runs of an algorithm with different parameters.
"""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
You can’t perform that action at this time.