pythresh
pythresh copied to clipboard
Add correct seeding to REGR thresholder
I integrated PyThresh into our TimeEval tool and I noticed that REGR builds a normal distribution without seeding the RNG. This leads to different results when calling it multiple times despite the same input:
import numpy as np
from pythresh.thresholds.regr import REGR
scores = np.random.default_rng().random(1000)
regr = REGR(random_state=42)
test1 = regr.eval(scores)
test2 = regr.eval(scores)
# this raises an AssertionError
np.testing.assert_array_equal(test1, test2)
This PR lets REGR expose a random_state
parameter to seed the NumPy RNG, similar to other thresholders.