# cumulative_num_comparisons_from_blocking_rules_chart_chartÂ¶

At a glance

Useful for: Counting the number of comparisons generated by Blocking Rules.

API Documentation: cumulative_num_comparisons_from_blocking_rules_chart()

What is needed to generate the chart? A linker with some data and a settings dictionary defining some Blocking Rules.

## Worked ExampleÂ¶

from splink.duckdb.linker import DuckDBLinker
import logging, sys
logging.disable(sys.maxsize)

settings = {
"blocking_rules_to_generate_predictions": [
block_on("first_name"),
block_on("surname"),
block_on("email")
]
}



Alternatively, Blocking Rules can be passed into the chart directly:

brs = [
block_on(["first_name", "dob"]),
block_on("surname"),
block_on("email")
]


### What the chart showsÂ¶

The cumulative_num_comparisons_from_blocking_rules_chart shows the count of pairwise comparisons generated by a set of blocking rules.

What the chart tooltip shows

The tooltip shows a number of statistics based on the bar that the user is hovering over, including:

• The blocking rule as an SQL statement.
• The number of additional pairwise comparisons generated by the blocking rule.
• The cumulative number of pairwise comparisons generated by the blocking rule and the previous blocking rules.
• The total number of possible pariwise comparisons (i.e. the Cartesian product). This represents the number of comparisons which would need to be evaluated if no blocking was implemented.
• The percentage of possible pairwise comparisons excluded by the blocking rule and the previous blocking rules (i.e. the Reduction Ratio). This is calculated as $$1-\frac{\textsf{cumulative comparisons}}{\textsf{total possible comparisons}}$$.

### How to interpret the chartÂ¶

Blocking rules are order dependent, therefore each bar in this chart shows the additional comparisons generated ontop of the previous blocking rules.

For example, the chart above shows an exact match on surname generates an additional 1351 comparisons. If we reverse the order of the surname and first_name blocking rules:

settings = {
"blocking_rules_to_generate_predictions": [
block_on("surname"),
block_on("first_name"),
block_on("email")
]
}



The total number of comparisons is the same (3,664), but now 1,638 have been generated by the surname blocking rule. This suggests that 287 record comparisons have the same first_name and surname.

### Actions to take as a result of the chartÂ¶

The main aim of this chart is to understand how many comparisons are generated by blocking rules that the Splink model will consider. The number of comparisons is the main primary driver of the amount of computational resource required for Splink model training, predictions etc. (i.e. how long things will take to run).

The number of comparisons that are appropriate for a model varies. In general, if a model is taking hours to run (unless you are working with 100+ million records), it could be helpful to reduce the number of comparisons by defining more restrictive blocking rules.

For instance, there are many people who could share the same first_name in the example above you may want to add an additonal requirement for a match on dob as well to reduce the number of records the model needs to consider.

settings = {
"blocking_rules_to_generate_predictions": [
block_on(["first_name", "dob"]),
block_on("surname"),
block_on("email")
]
}