Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix KeyError in example_auto_select_uq.py for Pareto mode compatibility#1131

Merged
SkBlaz merged 3 commits intomasterSkBlaz/py3plex:masterfrom
copilot/add-uq-stability-analysis-exampleSkBlaz/py3plex:copilot/add-uq-stability-analysis-exampleCopy head branch name to clipboard
Jan 17, 2026
Merged

Fix KeyError in example_auto_select_uq.py for Pareto mode compatibility#1131
SkBlaz merged 3 commits intomasterSkBlaz/py3plex:masterfrom
copilot/add-uq-stability-analysis-exampleSkBlaz/py3plex:copilot/add-uq-stability-analysis-exampleCopy head branch name to clipboard

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 17, 2026

The UQ example code assumed wins mode leaderboard structure (rank, algorithm columns), but the default Pareto mode uses evaluation_matrix with different column names (algorithm_id). This caused KeyErrors when accessing leaderboard columns and missing provenance keys.

Changes

examples/communities/example_auto_select_uq.py

  • Detect leaderboard structure dynamically and use appropriate column names
  • Make metrics_by_bucket access conditional (wins mode only)

py3plex/algorithms/community_detection/auto_select.py

  • Add uq_n_samples and uq_method to Pareto mode's selection_config for consistency with wins mode

Example

# Example now handles both modes gracefully
leaderboard = result.leaderboard

# Pareto mode: uses 'algorithm_id'
# Wins mode: uses 'algorithm' and 'rank'
display_cols = ['stability']
if 'algorithm_id' in leaderboard.columns:
    display_cols.insert(0, 'algorithm_id')
elif 'algorithm' in leaderboard.columns:
    if 'rank' in leaderboard.columns:
        display_cols.insert(0, 'rank')
    display_cols.insert(0, 'algorithm')

print(leaderboard[display_cols])
Original prompt

This section details on the original issue you should resolve

<issue_title>another community example</issue_title>
<issue_description>uv run example_auto_select_uq.py

Auto-Select with Uncertainty Quantification (UQ)

UQ provides stability analysis for community detection,
helping identify algorithms that produce robust results.

Note: UQ examples take longer as they run multiple iterations.

======================================================================
Example 1: Auto-select with UQ (seed-based)

Network: 15 nodes, 22 edges

Running auto-select with UQ (10 samples)...
This will take longer as algorithms are run multiple times...
2026-01-17 11:23:40 - py3plex.core.multinet - INFO - --------------------
2026-01-17 11:23:40 - py3plex.core.multinet - INFO - Network splitting in progress
2026-01-17 11:23:40 - py3plex.core.multinet - INFO - --------------------
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:00<00:00, 2534.87it/s]
BarnesHut Approximation took 0.01 seconds
Repulsion forces took 0.02 seconds
Gravitational forces took 0.00 seconds
Attraction forces took 0.00 seconds
AdjustSpeedAndApplyForces step took 0.00 seconds
2026-01-17 11:23:40 - py3plex.core.converters - INFO - Finished with layout..
/home/blazs/py3plex/py3plex/algorithms/community_detection/autocommunity_executor.py:60: UserWarning: Algorithm 'leiden' failed: multilayer_leiden_uq() got an unexpected keyword argument 'seed'
algorithm_results = _run_candidate_algorithms(

======================================================================
AutoCommunity v2 Selection Report (Pareto Mode)

Winner: louvain:default
Communities detected: 4
Coverage: 1.000

--- Why This Algorithm Won ---
✓ Dominated all other algorithms (sole Pareto-optimal solution)
• modularity: 0.524
• coverage: 1.000
• stability: 1.000

--- Trade-offs ---
(No other algorithms to compare)

--- Stability & Uncertainty ---
Partition stability: 1.000
→ High confidence in community assignments
Mean node confidence: 1.000

--- Null-Model Calibration ---
(Null-model calibration not enabled)

--- Graph Regime Interpretation ---
Degree heterogeneity: 0.263
Inter-layer coupling: 0.000
→ Weakly coupled layers

--- Reproducibility ---
Random seed: 42
Pareto selection: True
UQ enabled: True

======================================================================

--- Leaderboard with Stability Metrics ---
algorithm_id modularity coverage stability
louvain:default 0.52376 1.0 1.0

--- Stability Analysis ---
Higher stability values indicate more consistent partitions
across different random seeds/perturbations.

======================================================================
Example 2: Stability comparison across algorithms

Network: 25 node-layer pairs

Running auto-select with UQ to compare stability...
Using seed-based method for robustness testing...
2026-01-17 11:23:40 - py3plex.core.multinet - INFO - --------------------
2026-01-17 11:23:40 - py3plex.core.multinet - INFO - Network splitting in progress
2026-01-17 11:23:40 - py3plex.core.multinet - INFO - --------------------
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:00<00:00, 2517.97it/s]
BarnesHut Approximation took 0.01 seconds
Repulsion forces took 0.02 seconds
Gravitational forces took 0.00 seconds
Attraction forces took 0.00 seconds
AdjustSpeedAndApplyForces step took 0.00 seconds
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:00<00:00, 4193.88it/s]
BarnesHut Approximation took 0.01 seconds
Repulsion forces took 0.01 seconds
Gravitational forces took 0.00 seconds
Attraction forces took 0.00 seconds
AdjustSpeedAndApplyForces step took 0.00 seconds
2026-01-17 11:23:40 - py3plex.core.converters - INFO - Finished with layout..
/home/blazs/py3plex/py3plex/algorithms/community_detection/autocommunity_executor.py:57: UserWarning: Failed to compute some regime features: tuple index out of range
regime_features = _compute_graph_regime(network)
/home/blazs/py3plex/py3plex/algorithms/community_detection/autocommunity_executor.py:60: UserWarning: Algorithm 'leiden' failed: multilayer_leiden_uq() got an unexpected keyword argument 'seed'
algorithm_results = _run_candidate_algorithms(

=============================================...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 17, 2026 10:32
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add auto-select example with uncertainty quantification Fix KeyError in example_auto_select_uq.py for Pareto mode compatibility Jan 17, 2026
Copilot AI requested a review from SkBlaz January 17, 2026 10:36
@SkBlaz SkBlaz marked this pull request as ready for review January 17, 2026 11:14
@SkBlaz SkBlaz merged commit 7dc31d1 into master Jan 17, 2026
32 checks passed
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.

another community example

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.