Skip to content

Add ASW-based faultline strength scoring to Group - #305

Draft
mgmodell with Copilot wants to merge 7 commits into
mainfrom
copilot/calculate-faultline-strength
Draft

Add ASW-based faultline strength scoring to Group#305
mgmodell with Copilot wants to merge 7 commits into
mainfrom
copilot/calculate-faultline-strength

Conversation

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

This PR adds a faultline-strength capability to Group parallel to the existing diversity-score APIs, implementing an ASW-based approach for multiple subgroup structures. It introduces both direct group scoring and proposed-group scoring from email lists.

  • Public faultline scoring API

    • Added Group#calc_faultline_strength for persisted groups.
    • Added Group.calc_faultline_strength_for_group(users:) and Group.calc_faultline_strength_for_proposed_group(emails:) to mirror the existing diversity-score method family.
  • ASW computation pipeline

    • Builds per-user demographic profiles across categorical and numeric attributes already used by group composition logic.
    • Computes weighted pairwise dissimilarities (including categorical rescaling), evaluates agglomerative clusterings, and returns the maximum average silhouette width over valid subgroup counts (k = 2..n-1).
    • Preserves member multiplicity (duplicate profiles remain distinct members) and returns 0.0 for undersized groups.
  • Proposed-group query normalization

    • Normalizes incoming emails (trim, lowercase), removes empty tokens, deduplicates inputs, and performs case-insensitive matching.
    • Applies DISTINCT at query level so repeated email rows do not inflate subgroup/member counts.
  • Focused model coverage

    • Added tests for: undersized-group baseline, polarized-vs-homogeneous behavior, and proposed-group email normalization/deduplication paths.
score = Group.calc_faultline_strength_for_proposed_group(
  emails: ' A@example.com, a@example.com,  , B@example.com '
)
# => case-normalized, deduplicated, ASW-based faultline strength

Copilot AI linked an issue Sep 3, 2026 that may be closed by this pull request
Copilot AI and others added 4 commits September 3, 2026 23:57
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>
Copilot AI changed the title [WIP] Add fault-line strength calculation method to Group.rb Add ASW-based faultline strength scoring to Group Sep 4, 2026
Copilot AI requested a review from mgmodell September 4, 2026 00:01
@mgmodell

mgmodell commented Sep 4, 2026

Copy link
Copy Markdown
Owner

@copilot write Cucumber tests for this (like generate_diversity_scores.feature).

Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>

Copilot AI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot write Cucumber tests for this (like generate_diversity_scores.feature).

Added Cucumber coverage in commit 10d32a5 with a new feature (features/generate_faultline_strength.feature) and step definitions (features/step_definitions/generate_faultline_strength_steps.rb) for group scoring and proposed-group email normalization behavior.

@mgmodell

mgmodell commented Sep 4, 2026

Copy link
Copy Markdown
Owner

@copilot , if code is inspired by research, the calculations should be documented with references to the research that served as inspiration (in this case: Keivan et. al and Keivan et. al)

Co-authored-by: mgmodell <7279993+mgmodell@users.noreply.github.com>

Copilot AI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot , if code is inspired by research, the calculations should be documented with references to the research that served as inspiration (in this case: [Keivan et. al](https://journals.sagepub.com...

Added the research documentation in commit 7b34c9d with inline references in /home/runner/work/CoLab/CoLab/app/models/group.rb for the ASW faultline approach and the diversity-attribute weight rescaling method.

@mgmodell

mgmodell commented Sep 4, 2026

Copy link
Copy Markdown
Owner

@copilot what is the range of possible fault line strengths? Is it bounded?

Copilot AI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot what is the range of possible fault line strengths? Is it bounded?

Yes—it's bounded. In this implementation the returned faultline strength is in [0.0, 1.0] (rounded to 4 decimals). Silhouette values are at most 1, and the method also clamps negatives to 0 ([max_asw, 0.0].max), so you should never see values below 0 or above 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calculate fault-line strength using ASW

2 participants