Skip to content

Commit

Permalink
tune similarity metric weights
Browse files Browse the repository at this point in the history
  • Loading branch information
formularin committed Mar 6, 2023
1 parent bcd05f3 commit 562c6c4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions rba/community_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def compute_precinct_similarities(graph, name=None, verbose=False):
transformed_log_pop_2 = (data2["log_pop_density"] - min_log_pop_density) / log_pop_density_range
distances["pop_density"] = abs(transformed_log_pop_1 - transformed_log_pop_2)

distances["county"] = 1 if data1["COUNTYFP10"] == data2["COUNTYFP10"] else 0
distances["county"] = 0 if data1["COUNTYFP10"] == data2["COUNTYFP10"] else 1

distance_list = []
weight_list = []
Expand All @@ -118,7 +118,7 @@ def compute_precinct_similarities(graph, name=None, verbose=False):

if verbose:
edges_iter.set_description(
" ".join([f"{distances[metric]}_dist={round(dist, 3)}" for metric, dist in distances.items()])
" ".join([f"{metric}_dist={round(dist, 3)}" for metric, dist in distances.items()])
+ f" similarity={round(similarity, 3)}"
)

Expand Down
4 changes: 2 additions & 2 deletions rba/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
MINORITY_NAMES = ["black", "hispanic", "asian", "native", "islander"]

SIMILARITY_WEIGHTS = {
"race": 1.0,
"race": 1.5,
"votes": 1.0,
"pop_density": 1.0,
"county": 0.5
"county": 0.1
}

# Due logarithm domain redistriction
Expand Down
2 changes: 1 addition & 1 deletion rba/data/2010/maryland_communities.json

Large diffs are not rendered by default.

Loading

0 comments on commit 562c6c4

Please sign in to comment.