pythresh icon indicating copy to clipboard operation
pythresh copied to clipboard

Add correct seeding to REGR thresholder

Open SebastianSchmidl opened this issue 2 years ago • 0 comments

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.

SebastianSchmidl avatar Nov 04 '22 11:11 SebastianSchmidl