add funcs to calculate the cartesian and reduction ratio
@@ -86,3 +86,28 @@ def all_letter_combos(n):
combos.append("".join(s))
if len(combos) >= n:
return combos
+
+
+def calculate_cartesian(df_rows):
+ """
+ Calculates the cartesian product for the input df(s).
+ """
+ n = df_rows
+ numerator = n * (n - 1)
+ return numerator / 2
+
+
+def calculate_reduction_ratio(N, cartesian):
+ """
+ Args:
+ N (int): The number of record pairs generated by a
+ blocking rule.
+ cartesian (int): The cartesian product of your input
+ dataframe(s).
+
+ Generates the reduction ratio. This represents the % reduction
+ in the comparison space as a result of using your given blocking
+ rule. This is a measure of how much the Blocking Rule reduces
+ the total search space.
+ """
+ return 1 - (N / cartesian)
