You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
purify() stops before the tensor is pure when some weights are zero (randomized order) #702
interpret.utils.purify often returns a tensor that is not pure when some cells have zero weight. It happens with the default is_randomized=True and tolerance=0, even for 2D tensors:
The weighted row and column sums of the result are off by up to about 0.9 here, with scores of order 1. A pure solution always exists, because purification is the weighted least-squares projection onto the pure subspace. With is_randomized=False the same inputs purify to about 1e-16 (0 failures in 200). Tensors without zero weights, or large tensors such as 32×32, are fine. Small and medium tensors with empty cells fail often, for 3D and 4D as well (e.g. 3×3×3 with 30% empty cells: 38/40).
I think the cause is the exit condition in Purify.cpp, while(!(impurityPrev <= impurityCur)). The loop stops after the first sweep whose total |update| is not smaller than the previous sweep's. With a fresh random fiber order in each sweep, that sum is not monotone, and empty cells make convergence slow, so a single non-decreasing sweep usually comes long before convergence. A Python replica of the loop (same fiber updates, same exit rule) reproduces the failure rate: 179/200 random, 2/200 ordered. Exiting only after, say, 20 sweeps without a new minimum, or once the impurity reaches the tolerance, gives 0/200 with random order.
purify_result is off by default in EBM training, so this mostly affects direct users of purify. Nothing is raised, so the impure output is silent.
I don't have a toolchain to build libebm here, so I'm filing this rather than a PR. The same exit pattern is at the end of the multiclass loop (while(bRetry && !(impurityPrev <= impurityCur))).
(Found while cross-checking purify against its documented guarantees with Claude Code; I reviewed the analysis.)
Activity