Skip to content

Fix scale-dependent SPOT prototype selection - #703

Open
student-shivamm wants to merge 1 commit into
interpretml:mainfrom
student-shivamm:codex/spot-cost-scale
Open

student-shivamm wants to merge 1 commit into
interpretml:mainfrom
student-shivamm:codex/spot-cost-scale

Conversation

@student-shivamm

Copy link
Copy Markdown

Problem

SPOT_GreedySubsetSelection initializes its current minimum costs to 1,000,000. For valid costs above that bound, the initial gains are clipped to zero. This can select a worse prototype and produce incorrect weights, although multiplying all costs by a common positive scale should preserve the objective ordering.

import numpy as np
from interpret.utils import SPOT_GreedySubsetSelection

costs = np.array([[3.0, 4.0], [2.0, 3.0]]) * 1_000_000
indices, weights = SPOT_GreedySubsetSelection(costs, np.array([0.5, 0.5]), 1)

Upstream selects row 0, with a weighted cost of 3,500,000. Row 1 costs 2,500,000 and is selected for the unscaled matrix. With this patch, row 1 is selected at both scales.

Change

Use the maximum input cost as the initial upper bound. Keep objective bookkeeping in float64 to avoid integer overflow for large finite costs once the fixed cap is removed. The public signature, output shapes/types and lazy SciPy loading remain unchanged. No native/generated code or dependencies change.

Validation

  • Identical final regressions: 12 failures and 4 passing controls on main 4a492be, versus 16 passes with the patch. Covers selected indices, weights, input preservation and scales of 1, 1e6, 1e9 and 2**64, with an independent direct-objective reference.
  • Adjacent Python tests: 21 passed, 1 skipped because SHAP/sklearn are unavailable. The original SPOT smoke module also executes its collection-time assertions; these are not counted as extra test functions.
  • Repository-pinned Ruff 0.17.2 formatting and new-test lint pass. Four source-lint findings are identical on upstream and candidate. Source-scoped mypy 2.4.1 and git diff --check pass.
  • Windows, Python 3.12.14, NumPy 2.3.5 and SciPy 1.18.1. Full core/native/R/JS/OS/Python/packaging CI was not run. No model training, live services, performance claim or model-accuracy claim.

AI assistance: OpenAI Codex investigated, implemented and ran the recorded local checks. No independent human code review or production incident is claimed. Any required DCO declaration remains the contributor's action; no legal signing was performed by the assistant.

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.03%. Comparing base (4a492be) to head (dab8d33).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #703      +/-   ##
==========================================
- Coverage   67.82%   67.03%   -0.79%     
==========================================
  Files          77       77              
  Lines       11893    11893              
==========================================
- Hits         8066     7973      -93     
- Misses       3827     3920      +93     
Flag Coverage Δ
bdist_linux_311_python 62.96% <100.00%> (-4.58%) ⬇️
bdist_linux_312_python ?
bdist_linux_313_python ?
bdist_linux_314_python 62.86% <100.00%> (-4.59%) ⬇️
bdist_linuxarm_311_python 65.17% <100.00%> (-2.39%) ⬇️
bdist_linuxarm_312_python ?
bdist_linuxarm_313_python ?
bdist_linuxarm_314_python 65.07% <100.00%> (-2.40%) ⬇️
bdist_mac_311_python 65.97% <100.00%> (-1.73%) ⬇️
bdist_mac_312_python ?
bdist_mac_313_python ?
bdist_mac_314_python 66.86% <100.00%> (-0.77%) ⬇️
bdist_win_311_python 63.12% <100.00%> (-4.60%) ⬇️
bdist_win_312_python ?
bdist_win_313_python ?
bdist_win_314_python 63.02% <100.00%> (-4.61%) ⬇️
sdist_linux_311_python ?
sdist_linux_312_python ?
sdist_linux_313_python ?
sdist_linux_314_python ?
sdist_linuxarm_311_python ?
sdist_linuxarm_312_python ?
sdist_linuxarm_313_python ?
sdist_linuxarm_314_python ?
sdist_mac_311_python ?
sdist_mac_312_python ?
sdist_mac_313_python ?
sdist_mac_314_python ?
sdist_win_311_python ?
sdist_win_312_python ?
sdist_win_313_python ?
sdist_win_314_python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant