Skip to content

Commit d626114

Browse files
Merge branch 'UdayLab:main' into main
2 parents 9f3fde5 + b103cb8 commit d626114

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

PAMI/extras/graph/plotFrequentPatternSetsGraph.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
along with this program. If not, see <https://www.gnu.org/licenses/>.
2828
"""
2929

30+
import sys
31+
3032
import matplotlib.pyplot as plt
3133
from typing import Dict, Union
3234

@@ -78,31 +80,23 @@ def save(self, oFile: str) -> None:
7880
plt.savefig(oFile)
7981
plt.close()
8082

81-
def getStatistics(self) -> Dict[str, Union[int, float]]:
83+
def getStatistics(self) -> None:
8284
if not self.patternCounts:
83-
return {}
85+
return None
86+
87+
minLen = min(self.patternCounts.keys())
88+
maxLen = max(self.patternCounts.keys())
8489

85-
return {
86-
'totalPatterns': sum(self.patternCounts.values()),
87-
'minPatternSize': min(self.patternCounts.keys()),
88-
'maxPatternSize': max(self.patternCounts.keys()),
89-
'patternSizeDistribution': self.patternCounts
90-
}
90+
print("Statistics:")
91+
print(f" Length range: {minLen}-{maxLen}")
92+
print(" Pattern Size Distribution <size: #count>:")
93+
for size, count in sorted(self.patternCounts.items()):
94+
print(f" {size}:{count}")
95+
return None
9196

9297

9398
if __name__ == "__main__":
94-
samplePatterns = {
95-
('A',): 100,
96-
('B',): 150,
97-
('C',): 120,
98-
('A', 'B'): 80,
99-
('A', 'C'): 70,
100-
('B', 'C'): 90,
101-
('A', 'B', 'C'): 50,
102-
('D',): 110,
103-
('A', 'D'): 60,
104-
('B', 'D'): 65,
105-
}
106-
107-
obj = plotFrequentPatternSetsGraph(samplePatterns)
99+
# Usage: python plotFrequentPatternSetsGraph.py patterns.txt
100+
obj = plotFrequentPatternSetsGraph(sys.argv[1])
108101
obj.plot()
102+
obj.getStatistics()

0 commit comments

Comments
 (0)