compare_site_allocation
site_solutions.SolutionComparator.compare_site_allocation(
by='demand',
metric='proportion',
config_a=None,
config_b=None,
matrix=None,
demand=None,
)Compare site_allocation_summary() between set_a and set_b, e.g. a 2-site solution against a 3-site solution, to see whose demand a new site actually took, or how much further people would have to travel if a site were closed.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| by | (demand, regions) | Passed to both sets’ site_allocation_summary(). |
"demand" |
| metric | (proportion, average_travel_cost) | Which site_allocation_summary() column to compare. “proportion” answers “whose demand moved?”; “average_travel_cost” answers “how much further (or less far) do the people closest to this site now have to travel?” – the comparison inspired by Gill Baker’s work using average travel distance per patient to show that centralising services would roughly double typical travel distance, while a third site added little further benefit (see site_allocation_summary). |
"proportion" |
| config_a | dict | Keyword arguments forwarded to set_a.site_allocation_summary() and set_b.site_allocation_summary() respectively (e.g. {"solution_rank": 2}), selecting which solution from each set to summarise. Default to {"solution_rank": 1}. |
None |
| config_b | dict | Keyword arguments forwarded to set_a.site_allocation_summary() and set_b.site_allocation_summary() respectively (e.g. {"solution_rank": 2}), selecting which solution from each set to summarise. Default to {"solution_rank": 1}. |
None |
| matrix | str | Passed to both sets’ site_allocation_summary(). |
None |
| demand | str | Passed to both sets’ site_allocation_summary(). |
None |
Returns
| Name | Type | Description |
|---|---|---|
| pandas.DataFrame | Indexed by the union of both solutions’ site names, in canonical site-index order. Columns are self.labels[0], self.labels[1], and difference (labels[0] - labels[1], matching get_metric_summary’s direction). |
Notes
With metric="proportion" (the default), NaN and 0.0 mean different things and are not interchangeable: NaN means the site is not in that solution at all (not opened), while 0.0 means the site is opened but is closest to no region. Collapsing the two would erase the point of the comparison – e.g. comparing a 2-site solution against a 3-site one, the new site’s row is NaN in the 2-site column, not 0.0.
With metric="average_travel_cost", this distinction does not apply: a site that is opened but closest to nothing has no travel cost to average either, so both “not opened” and “opened but empty” show up as NaN.