Skip to content

Commit 9f0bf33

Browse files
improved getStatistics
1 parent fdd7093 commit 9f0bf33

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

PAMI/extras/graph/plotFrequentPatternSetsGraph.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,24 @@ def save(self, oFile: str) -> None:
7878
plt.savefig(oFile)
7979
plt.close()
8080

81-
def getStatistics(self) -> Dict[str, Union[int, float]]:
81+
def getStatistics(self) -> None:
8282
if not self.patternCounts:
83-
return {}
83+
return None
8484

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-
}
85+
minLen = min(self.patternCounts.keys())
86+
maxLen = max(self.patternCounts.keys())
87+
88+
print("Statistics:")
89+
print(f" Length range: {minLen}-{maxLen}")
90+
print(" Pattern Size Distribution <size: #count>:")
91+
for size, count in sorted(self.patternCounts.items()):
92+
print(f" {size}:{count}")
93+
return None
9194

9295

9396
if __name__ == "__main__":
9497
samplePatterns = {
95-
('A',): 100,
98+
('A',): 110,
9699
('B',): 150,
97100
('C',): 120,
98101
('A', 'B'): 80,
@@ -106,3 +109,4 @@ def getStatistics(self) -> Dict[str, Union[int, float]]:
106109

107110
obj = plotFrequentPatternSetsGraph(samplePatterns)
108111
obj.plot()
112+
obj.getStatistics()

0 commit comments

Comments
 (0)